I have been working on a project and have run into a brick wall. I researched around the web and it seems that no one is having the same problem as me and it is upsetting. I am unable to get the full xml in return from simplexml_load_string()
. When I use simplexml at all it gives me a problem. The :
is just where most think the problem is. If you look at the sales rankings tag in the bottom example and then look at the hierarchy you will see that there is not one namespace. Here is the original xml:
<GetMatchingProductForIdResponse xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01">
<GetMatchingProductForIdResult Id="883028968343" IdType="UPC" status="Success">
<Products xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01" xmlns:ns2="http://mws.amazonservices.com/schema/Products/2011-10-01/default.xsd">
<Product>
<Identifiers>
<MarketplaceASIN>
<MarketplaceId>ATVPDKIKX0DER</MarketplaceId>
<ASIN>B007C435CW</ASIN></MarketplaceASIN>
</Identifiers>
<AttributeSets>
<ns2:ItemAttributes xml:lang="en-US">
<ns2:Binding>Apparel</ns2:Binding>
<ns2:Brand>Secret Wishes</ns2:Brand>
<ns2:Color>Black</ns2:Color>
<ns2:Department>womens</ns2:Department>
<ns2:Feature>Black and gold musketeer or pirate costume</ns2:Feature>
<ns2:Feature>Features strapless corset with lace up back and matching mini skirt</ns2:Feature>
<ns2:Feature>Hat and choker included</ns2:Feature>
<ns2:Feature>Boots and sword available separately</ns2:Feature>
<ns2:Feature>Sexy wishes for playful adults is a division of rubies costume company</ns2:Feature>
<ns2:Genre>Historical</ns2:Genre>
<ns2:IsAdultProduct>false</ns2:IsAdultProduct>
<ns2:Label>Secret Wishes</ns2:Label>
<ns2:Manufacturer>Secret Wishes</ns2:Manufacturer><ns2:Model>889683XS</ns2:Model>
<ns2:PackageDimensions>
<ns2:Height Units="inches">1.10</ns2:Height>
<ns2:Length Units="inches">14.50</ns2:Length>
<ns2:Width Units="inches">11.40</ns2:Width>
<ns2:Weight Units="pounds">0.90</ns2:Weight>
</ns2:PackageDimensions>
<ns2:ProductGroup>Apparel</ns2:ProductGroup>
<ns2:ProductTypeName>ADULT_COSTUME</ns2:ProductTypeName>
<ns2:Publisher>Secret Wishes</ns2:Publisher>
<ns2:Size>X-Small</ns2:Size>
<ns2:SmallImage>
<ns2:URL>http://ecx.images-amazon.com/images/I/41YPo629q4L._SL75_.jpg</ns2:URL>
<ns2:Height Units="pixels">75</ns2:Height>
<ns2:Width Units="pixels">37</ns2:Width>
</ns2:SmallImage>
</AttributeSets>
<SalesRankings>
<SalesRank>
<ProductCategoryId>office_product_display_on_website</ProductCategoryId>
<Rank>259</Rank>
</SalesRank>
</SalesRankings>
ECT...
The response I get when I do print_r(simplexml_load_string(curl_exec($ch);
is this:
SimpleXMLElement Object
(
[GetMatchingProductForIdResult] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Id] => 883028968343
[IdType] => UPC
[status] => Success
)
[Products] => SimpleXMLElement Object
(
[Product] => SimpleXMLElement Object
(
[Identifiers] => SimpleXMLElement Object
(
[MarketplaceASIN] => SimpleXMLElement Object
(
[MarketplaceId] => ATVPDKIKX0DER
[ASIN] => B007C435CW
)
)
[AttributeSets] => SimpleXMLElement Object
(
)
[Relationships] => SimpleXMLElement Object
(
[VariationParent] => SimpleXMLElement Object
(
[Identifiers] => SimpleXMLElement Object
(
[MarketplaceASIN] => SimpleXMLElement Object
(
[MarketplaceId] => ATVPDKIKX0DER
[ASIN] => B00B7DAJAA
)
)
)
)
[SalesRankings] => SimpleXMLElement Object
(
)
)
)
)
I do not understand what the possible problem is. My main goal for this data is to push it to JSON. If someone could help me out, I would greatly appreciate it. Thanks!