I am attempting to parse an xml file with attributes, and keep getting an empty array. Here is a sample of the xml, which is parsed as a simplexml_load_string:
<NumberOfOfferListings>
<OfferListingCount condition="Any">61</OfferListingCount>
<OfferListingCount condition="Used">45</OfferListingCount>
<OfferListingCount condition="New">16</OfferListingCount>
</NumberOfOfferListings>
Here is the php code that I am using
$priceComp_xml = amazonCompPrice_xml($asin);
$compPricing = $priceComp_xml->xpath('OfferListingCount[@condition="Any"]');
amazonCompPrice($asin) is the parsed xml file based on the ASIN value.
I need to extract just:
<OfferListingCount condition="Any">61</OfferListingCount>
I have looked at many examples on here to get to this point, and it looks like what I have is correct, just returns an empty array when I use either print_r($compPricing) or var_dump. How do I fix this to get the information that I need?? I can upload any more snippets of code that will help resolve this issue.
<OffsetListingCount>which is a child (c.f, descendant) of whatever$priceComp_xmlholds. The simplest change would be to use//OfferListingCount[@condition="Any"]