My mistake, the original gzip file containing the xml file didn't have the in_stock value specified!
This is driving me bonkers. Why can't I get all attibutes from an element?
I'm not a big expert on XML but I've got by until now.
Here is a sample of the Dixons product feed:
<merchantProductFeed>
<merchant id="1597">
<prod id="113458948" in_stock="yes">
<pId>00776063</pId>
<price>
<buynow>449.99</buynow>
</price>
</prod>
</merchant>
</merchantProductFeed>
I can get the price and the PID no problem. I can get the merchant ID (1597) and the prod id (113458948) but I can't get the in_stock attribute.
I am using this to get the attribute id from each prod element:
(this basic example just echoes to the screen for testing purposes)
foreach ($products_file->merchant->prod as $prod) {
echo "PID=" . $prod->pId . "<br>"; //works ok!
echo "£" . $prod->price->buynow . "<br>"; //works ok!
echo $prod->attributes()->id . "<br>"; //works ok!
}
So
echo $prod->attributes()->in_stock . "<br>";
products a blank string. Any ideas please?
My mistake, the original gzip file containing the xml file didn't have the in_stock value specified!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks