First off, you need to access the url thu file_get_contents
, Consider this example:
$url = 'http://developer.ebay.com/DevZone/finding/CallRef/Samples/findCompletedItems_basic_out_xml.txt';
// access the url and get that file
$contents = file_get_contents($url);
// convert it to an xml object
$contents = simplexml_load_string($contents);
$count = 0; // initialize counter
// loop and search for that
foreach($contents->searchResult->item as $key => $value) {
if(isset($value->sellingStatus->sellingState) && $value->sellingStatus->sellingState == 'EndedWithSales') {
// if that key exists and is contains EndedWithSales, increment it
$count++;
}
}
// at the end of the loop echo it or whatever you wanted to do
echo "<script>alert('You have $count ocurrances of EndedWithSales in this XML');</script>";