Hello Guys I've been working with XML datafeeds and I have a feed that holds 3,000 products. However, I only want to use products from the feed with 'dahon' in the name. This is only about 12 of the 3,000. Can I modify my PHP to only insert the products with 'dahon' in the name? Here's my code I'm using... $xml = simplexml_load_file("foldingdatafeed_79329.xml"); foreach($xml->merchant->prod as $product){ $productid = $product->id; $name = $product->text->name; $descrip = $product->text->desc; $sql = "INSERT INTO products (productid, productname, productdescription) VALUES ('$productid', '$name', '$descrip')"; PHP: Any help would be appreciated
$xml = simplexml_load_file("foldingdatafeed_79329.xml"); foreach($xml->merchant->prod as $product){ $productid = $product->id; $name = $product->text->name; $descrip = $product->text->desc; $pos = strpos($name,"dahon"); if($pos === false) { } else { $sql = "INSERT INTO products (productid, productname, productdescription) VALUES ('$productid', '$name', '$descrip')"; ... }
Can I ask one more thing. I'm having trouble inserting the merchant name and product id. The XML holding the info starts with them like this.. <merchant id="1302" name="Evans Cycles"> <prod id="32672061"> <text><name>Pashley Princess Classic Hybrid bike</name>......................</prod> How can I define the merchant name and product id in the code I'm using. foreach($xml->merchant->prod as $product){ $productid = $product->id; $name = $product->text->name; $descrip = $product->text->desc; PHP: