 2012-06-19 20:40 | I read the topic about generation XLM. I can not understand how to show the name of category ?
<?php $myURL = "http://stock.lv/"; $file = file("db/ru_products.php"); $fileIMG = file("db/ru_products_files.php"); $fileCATN = file("db/ru_pages.php"); $fileCATP = file("db/ru_products_pages.php"); $myURLIMG = "".$myURL."files/";
function change2Latin( $sContent ){ return str_replace( Array( 's', 'a', 'z', 'z', 'e', 'l', 'o', 'c', 'n', 'S', 'A', 'Z', 'Z', 'E', 'L', 'O', 'C', 'N', 'a', 'c', 'd', 'e', 'e', 'i', 'n', 'r', 'a', 't', 'u', 'u', 'y', 'z', 'A', 'C', 'D', 'E', 'E', 'I', 'N', 'R', 'S', 'T', 'U', 'U', 'Y', 'Z', 'a', 'l', 'l', 'r', 'A', 'A', 'L', 'R', 'o', 'u', '?', 'O', 'U' ), Array( 's', 'a', 'z', 'z', 'e', 'l', 'o', 'c', 'n', 'S', 'A', 'Z', 'Z', 'E', 'L', 'O', 'C', 'N', 'a', 'c', 'd', 'e', 'e', 'i', 'n', 'r', 's', 't', 'u', 'u', 'y', 'z', 'A', 'C', 'D', 'E', 'E', 'I', 'N', 'R', 'S', 'T', 'U', 'U', 'Y', 'Z', 'a', 'l', 'l', 'r', 'A', 'L', 'L', 'R', 'o', 'u', 'S', 'O', 'U' ), $sContent ); } // end function change2Latin
function change2Url( $sContent ){ return strtolower( change2Latin( str_replace( Array( ' ', '»', '/', '$', '\'', '"', '~', '\\', '?', '#', '%', '+', '^', '*', '>', '<', '@', '|', '"', '%', ':', '&', ',', '=', '--', '--', '[', ']', 'λ', '?', ' ' ), Array( '-', '', '-', '-', '', '', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '', '-', '-', '-', '-', '(', ')', '', '-', '' ), trim( $sContent ) ) ) ); } // end function change2Url
function trimTags($input, $validTags = '') { $regex = '#\s*<(/?\w+)\s+(?:on\w+\s*=\s*(["\'\s])?.+? \(\1?.+?\1?\);?\1?|style=["\'].+?["\'])\s*>#is'; return preg_replace($regex, '<${1}>',strip_tags($input, $validTags)); }
$txt = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"."\n"; $txt .= "<root>"."\n";
$i=0; foreach($fileIMG as $dataIMG) { $temp = explode("$",$dataIMG); $ImgID[i] = $temp[1]; $ImgName[$ImgID[i]] = $temp[2]; $i++; }
$i=0;
foreach($file as $data) { list($iPosition, $sName, $sPrice, $mPrice, $aData, $iProduct, $sAvailable, $iStatus, $sDescriptionShort) = explode("$",$data); if ($i>0) { $myFinalURL = $myURL."?".$iPosition.",".change2Url( $sName ); $myFinalURLIMG = $myURLIMG.$ImgName[$iPosition]; if ($sAvailable ==0) $sAvailable=0;
//uprava popisu $sDescriptionShort = str_replace("|n|", " ", $sDescriptionShort); $sDescriptionShort = trimTags($sDescriptionShort); $txt .= "<item>"."\n"; $txt .= "<poss>$iPosition</poss>"."\n"; $txt .= "<name>$sName</name>"."\n"; $txt .= "<link>$myFinalURL</link>"."\n"; $txt .= "<price>$mPrice</price>"."\n"; $txt .= "<image>$myFinalURLIMG</image>"."\n"; $txt .= "<category_full>Satelitu un kabelu televizija</category_full>"."\n"; <<< ----- HOW TO SWOW THE NAME OF CATEGORY !!! $txt .= "<category_link>$myURL</category_link>"."\n"; $txt .= "<manufacturer>Intersat</manufacturer>"."\n"; $txt .= "<model>$sName</model>"."\n"; $txt .= "<in_stock>$sAvailable</in_stock>"."\n";
$txt .= "</item>"."\n"; } $i++; };
$txt .= "</root>"."\n";
//vypis hodnot echo $txt;
$dom_xml= new DomDocument(); $dom_xml->loadXML($txt); $path="intersat.xml"; echo $dom_xml->save($path); ?>
please, help !!!!
» Quick.Cart v4.x |