sktt Posted November 25, 2010 Share Posted November 25, 2010 Hi, Im trying to grab some data from a XML generated by an external server. I know how to grab from XML without attributes, but I cant seem to wrap my head around the structure of this file. What would be easiest way to get the value of the "dbnr" field? Part of the XML file: <data> <location> <field name="id" format="Long">xxxxxx</field> <field name="dbnr" format="Long">xxxxxx</field> <field name="jobnr" format="Long">xxxxxx</field> <field name="job_type" format="String" maxlen="50">xxxxxx</field> <field name="job_category" format="String" maxlen="50">xxxxxx</field> </location> </data> Link to comment https://forums.phpfreaks.com/topic/219790-grabbing-data-from-xml-with-attributes/ Share on other sites More sharing options...
MrXHellboy Posted November 25, 2010 Share Posted November 25, 2010 preg_match_all('@<field name="dbnr" format="Long">(.*)<\/field>@', $a, $matches); echo '<pre>'. print_r($matches, true).'</pre>'; Link to comment https://forums.phpfreaks.com/topic/219790-grabbing-data-from-xml-with-attributes/#findComment-1139422 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.