tjverge Posted February 1, 2011 Share Posted February 1, 2011 The following code should output 1743425391, but it does not show anything <?php $xml_feed_url = 'http://api.eve-online.com/eve/CharacterID.xml.aspx?names=TX1'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $xml_feed_url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $xml = curl_exec($ch); curl_close($ch); $xmlr = new SimpleXMLElement($xml); $charid = $xmlr->result->characterID; echo $charid; ?> The xml is: <eveapi version="2"> <currentTime>2011-02-01 05:22:38</currentTime> − <result> − <rowset name="characters" key="characterID" columns="name,characterID"> <row name="TX1" characterID="1743425391"/> </rowset> </result> <cachedUntil>2011-03-01 05:22:38</cachedUntil> </eveapi> Any ideas where I went wrong? Link to comment https://forums.phpfreaks.com/topic/226314-php-and-xml-not-showing-data/ Share on other sites More sharing options...
tjverge Posted February 1, 2011 Author Share Posted February 1, 2011 not sure if it helps but when I use print_r($xmlr); it returns SimpleXMLElement Object ( [@attributes] => Array ( [version] => 2 ) [currentTime] => 2011-02-01 05:57:30 [result] => SimpleXMLElement Object ( [rowset] => SimpleXMLElement Object ( [@attributes] => Array ( [name] => characters [key] => characterID [columns] => name,characterID ) [row] => SimpleXMLElement Object ( [@attributes] => Array ( [name] => TX1 [characterID] => 1743425391 ) ) ) ) [cachedUntil] => 2011-03-01 05:57:30 ) Link to comment https://forums.phpfreaks.com/topic/226314-php-and-xml-not-showing-data/#findComment-1168223 Share on other sites More sharing options...
tjverge Posted February 1, 2011 Author Share Posted February 1, 2011 updated code to $charid = $xmlr->result->rowset->row['characterID']; solved problem Link to comment https://forums.phpfreaks.com/topic/226314-php-and-xml-not-showing-data/#findComment-1168301 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.