Working with XML and PHP

You can work with xml in any language and php is one among them. If you are familiar with the DOM, you can work the DOM itself using php. The steps to work with xml in php too are the same as you would do in other languages.


_______________________________________________


You have to create a new DOM document and then load the xml file you are going to work with into it. Then you will be using the functions available to navigate through the xml document to get the elements and their values and then print it out on the screen.

The command new DOMDocument(); is used to create a new document object and the command load('xmlfile.xml'); to load the xml file you need.

You can use getElementsByTagName("element_name") to get all the elements with that tag and store them in an array and then use that particular array's item(n)->nodeValue to get the value of a particular node. You can loop through the node using a 'for' loop and print the values of each node.

The PHP installations include a SAX parser. You can use this parser to parse the xml files. It is another way to work with the xml file.




_______________________________________________

FREE Subscription

Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.

Name:
Email:

Note : We never rent, trade, or sell my email lists to
anyone. We assure that your privacy is respected
and protected.

_______________________________________




 

 

FREE Subscription

Stay Current With the Latest Technology Developments Realted to XML. Signup for Our Newsletter and Receive New Articles Through Email.

Name:

Email:

Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.

 

 

Add to My Yahoo!

Visit XML Training Material Guide Homepage

 

 

Copyright - © 2004 - 2017 - All Rights Reserved.