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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.