How can I read XML file..

keval007

Junior Member
Joined
Jun 12, 2012
Messages
144
Reaction score
26
I have attached one XML file which I want to read it in PHP. The file is to complex to understand, can any one give small code explanation to read this xml file.
 

Attachments

As jazzc noted, you could use SimpleXML or any of the other XML parsing libraries available on php.net.

Personally I like to use the Simple HTML DOM parser (which is available on sourceforge) to traverse the DOM/XML trees and spit out data. The class is tiny and useful.

What you will need to do (assuming you need to access the data within the curr_custs_aff block) is navigate to <root>, then <curr_custs_aff>, and finally <areas>. Once you are there you're going to have to select the children of <areas> and make sure they're after the area_name that you want to pull data from. It would be much easier if the XML was, well, valid I guess. It's kind of all over the place to be honest. This is honestly one of the main reasons I wish everyone would switch to a json standard =[.

Hope I helped!
 
Last edited:
Back
Top