Jump to content

How to read an XML file using PHP ?


tmyonline

Recommended Posts

Hi guys:

 

I have an xml file (donor_list.xml) which I read in using php as follow:

 

  $xml = new SimpleXMLElement(file_get_contents('donor_list.xml'));

 

and then I got its content out using the "foreach" construct.

 

Suppose this xml file consists of 3 parts: part A, part B, and part C.

 

Suppose I don't want to read in the whole xml document but rather just a particular part, say part B.  Is there a function in PHP that specifies where to begin reading and where to stop reading the xml file ?

 

Alternatively, if I use XPath, how should I approach this ?  Example(s) will help.  Thanks so much!

Link to comment
https://forums.phpfreaks.com/topic/91973-how-to-read-an-xml-file-using-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.