HOW TO READ XML FILE IN PHP

Manoj Bhatt

Total Post:154

Points:1086
Posted by  Manoj Bhatt
PHP 
PHP
 1866  View(s)
Ratings:
Rate this:

Hi Guys,

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

Thanks

  1. Arun Singh

    Post:68

    Points:476
    Re: How to read xml file in PHP

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!