how to extrapolate information from XML file in php -


Using file_get_conents to retrieve an XML file.

Let's say that the XML file looks like this

  & lt; Tag1 & gt; & Lt; Subtag1 & gt; Information & lt; / Subtag2 & gt; & Lt; / Tag1 & gt;  

How do I go about recovering information from that XML file?

You can use to retrieve your information:

  $ xml = simplexml_load_file ('file.xml'); $ Value = $ xml- & gt; Tag 1-> Subtag1; Echo $ value; // Output "info"  

If you want to loop through subtags:

  // method is a foreach ($ xml-> tag 1-> children () $ as subtag) $ $ dumb $ subtag "\ N"; } // method two $ i = 1; While ($ subtag = $ xml- & gt; tags 1-> {"subtag". $ I})! == faucet) {echo $ subtag "\ N"; $ I ++; }  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -