PHP simple_xml object array trouble [closed]

bikecrazyy

New Member
\[quote\] Possible Duplicate:
How to access element attributes with SimpleXml?
Get attributes and values using SimpleXML \[/quote\]I am trying to parse XML. The XML I am trying to parse:\[code\]<api><warnings><recentchanges xml:space="preserve">Action 'patrol' is not allowed for the current user</recentchanges></warnings><query><recentchanges><rc type="edit" ns="0" title="Article Title" rcid="54" pageid="6" revid="47" old_revid="46" timestamp="2012-06-19T15:55:38Z"/></recentchanges></query><query-continue><recentchanges rcstart="2012-06-19T15:36:40Z"/></query-continue></api>\[/code\](I am using the mediawiki api)I get the XML, and send it through simple_xml as so:\[code\] $xml = file_get_contents('en.wikipedia.org/w/api.php?action=query&list=recentchanges&rctoken=patrol&rclimit=1&format=xml'); $data = http://stackoverflow.com/questions/11105748/simplexml_load_string($xml); print_r($data->query->recentchanges->rc);\[/code\]That returns \[code\]SimpleXMLElement Object( [@attributes] => Array ( [type] => edit [ns] => 0 [title] => Article [rcid] => 54 [pageid] => 6 [revid] => 47 [old_revid] => 46 [timestamp] => 2012-06-19T15:55:38Z ))\[/code\]However, I cannot figure out how to access data inside the @attributes array. How would I do this?
 
Back
Top