Jump to content

Php and XML - not showing data


tjverge

Recommended Posts

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

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 ) 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.