parsing a xml to get some values

Posted by Joan Silverstone on Stack Overflow See other posts from Stack Overflow or by Joan Silverstone
Published on 2011-03-13T16:01:03Z Indexed on 2011/03/13 16:09 UTC
Read the original article Hit count: 219

Filed under:
|
|

Hello, i have this xml:

http://www.managerleague.com/export_data.pl?data=transfers&output=xml&hide_header=0

These are player sales from a browser game. I want to save some fields from these sales. I am fetching that xml with curl and storing on my server. Then do the following:

$xml_str = file_get_contents('salespage.xml');
$xml = new SimpleXMLElement($xml_str);
$items = $xml->xpath('*/transfer');

print_r($items);

foreach($items as $item) {
    echo $item['buyerTeamname'], ': ', $item['sellerTeamname'], "\n";
}

The array is empty and i cant seem to get anything from it. What am i doing wrong?

© Stack Overflow or respective owner

Related posts about php

Related posts about Xml