![]() |
ImplementationRetrieving by XML fileThe XML files are:
This can be easily from php:
function getProducts($productName) { // Returns arrayed collection of the product name or all products
if ($productName) $productname="_".$productname;
}
$pages=array(); $id="aBcDeFgHiJ"; // Your site code $xml = simplexml_load_file("http://www.scrapeshop.co.uk/".$id.$productname.".xml"; foreach($xml->children() as $child) {
$pages[$child->getName()]=array();
}foreach($child->children() as $page){
$thisPage=array();
}
foreach($child->children() as $kid) $thisPage[$kid->getName()]=$kid; $pages[$child->getName()][]=$thisPage; return $pages; // $pages contains an array collection of the single product To process the response from getProducts(), use something like:
$products=getProducts(null);
foreach($products as $product=>$p) {
if ($product=="error") {
}
echo("Error:".$p);
}else if ($product=="action") {
echo("Action:".$p);
}else{
echo($product);
}
foreach($p as $page) { echo("<div style='border:1px solid #bbbbbb'>");
}
foreach($page as $record) foreach($record as $k=>$v) {
// retrieves the product's fields and values
}echo("<div>$k = $v</div>"); echo("</div>"); | ![]() |