I would like to get the count of only items inside this file with sellingstatus->sellingstate
of EndedWithSales
ONLY, and perhaps also get the count for EnededWithoutSales
.
<sellingStatus>
<currentPrice currencyId="USD">25.0</currentPrice>
<convertedCurrentPrice currencyId="USD">25.0</convertedCurrentPrice>
<bidCount>1</bidCount>
<sellingState>EndedWithSales</sellingState>
</sellingStatus>
How would I go about passing this argument in php?
Here is a link to the sample of XML: http://developer.ebay.com/DevZone/finding/CallRef/Samples/findCompletedItems_basic_out_xml.txt.
Can anyone help out?
First off, you need to access the url thu
file_get_contents
, Consider this example:You can load the XML into an DOMDocument, create an Xpath instance for it an just fetch the count.
Output:
Xpaths
count()
function returns the number of nodes in defined by an expression.The first
searchResult
element in the document://ebay:searchResult[1]
The
item
elements in the firstsearchResult
//ebay:searchResult[1]/ebay:item
Items with a
sellingState
"EndedWithSales"//ebay:searchResult[1]/ebay:item[ebay:sellingStatus/ebay:sellingState = "EndedWithSales"]