php - using simplexml_load_file() to get attributes from xml file for Amazon Affiliate API -
i using amazon affiliate api here. new of actually.
i have php code generate working url products, having issues extracting data url's generated xml. looking return formattedprice xml.
here example of xml file: https://pastebin.com/hnttevfv
here code trying pull "formattedprice". neither of examples below working , returning empty values.
sidenote: $request_url full http:// valid url of xml file.
$getxml = simplexml_load_file($request_url); $price = $getxml->itemlookupresponse->items->item->itemattributes->listprice['formattedprice'];
nor does
$price = $getxml->itemlookupresponse->items->item->itemattributes->listprice->formatedprice;
every xml document has single "root element". in example, top-level element <itemlookupresponse>
.
when load document in simplexml, first object gives root element. access chlidren of element ->elementname
notation.
so instead of $getxml->itemlookupresponse->items
should write $getxml->items
.
Comments
Post a Comment