Home > DeveloperSection > Forums > How to read xml file in PHP
Manoj Bhatt
Manoj Bhatt

Total Post:153

Points:1079
Posted on    November-30-2011 1:33 AM

 PHP PHP 
Ratings:


 1 Reply(s)
 1603  View(s)
Rate this:

Hi Guys,

Can someone tell me, how to read xml file in php?

Thanks



Arun Singh

Total Post:68

Points:476
Posted on    December-01-2011 6:41 AM

Hi Manoj Bhatt,
To read XML file in PHP, you can use the following code:
 // Create DOMDocument object
           $xmlDoc = new DOMDocument();
// load XML file
            $xmlDoc->load("YourFile.xml");
            $ptag = $xmlDoc->getElementsByTagName('ParentNode');
            $childQType=$ptag->item($i)->getElementsByTagName('ChildNode');
            echo $childQType->item(0)->childNodes->item(0)->nodeValue;  
So in the same manner you can get all nodes values.              

Modified On Dec-01-2011 06:49:25 AM

Don't want to miss updates? Please click the below button!

Follow MindStick