Simple_XML Class: Getting attribute and information on the info node

souljaboy

New Member
I am pulling out information using the ANN api. I used the simpleXML class to get the information.\[code\]function explodeTest() { $result = $this->_restGenerator($this->ann, '6236'); //print_r($result); foreach ($result->anime as $data) { print_r($data->info); } }\[/code\]_restGenerator function:\[code\]function _restGenerator($url,$q) { $url = $url . strtolower($q); if(strlen($q) > 0) { $q = file_get_contents($url); //$q = simplexml_load_file($url) return simplexml_load_string($q); } }\[/code\]Constants:\[code\]$this->ann = 'http://cdn.animenewsnetwork.com/encyclopedia/api.xml?anime=';\[/code\]When I run the function, I get this :\[code\]SimpleXMLElement Object ( [@attributes] => Array ( [gid] => 3506750509 [type] => Picture [src] => http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/A6236-259.jpg ) )\[/code\]But the actual XML tag is displayed as this:\[code\]<anime id="6236" gid="1601610894" type="TV" name="Gintama" precision="TV" generated-on="2012-07-07T04:58:39Z"> <info gid="3506750509" type="Picture" src="http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/A6236-259.jpg"/> <info gid="1229282479" type="Main title" lang="JA">Gintama</info> <info gid="556528412" type="Alternative title" lang="RU">
 
Back
Top