Using PHP for XML parsingThe Document Object Model (DOM) and the SAX Parser are commonly used for parsing an xml document using PHP. Most of the developers would have use the DOM is other languages too for parsing an xml document. It is an easy way to do and there is a limitation in it. If the xml file is large it is difficult to handle it using DOM. In the case of a SAX parser you can handle large files easily. With the DOM you have to create a new document object and then load the xml file needed in it. Then using the functions available to navigate through the xml document, you can navigate and get the values of the nodes and print it out. In PHP you can use, new DOMDocument(), load('xmlfile.xml'), getElementsByTagName(), and item(n)->nodeValue to work with the xml document. When you use the getElementsByTagName function, all the elements in that name will be loaded in an array. Then you have to loop through the array to get the values of individual elements through item(n)->nodeValue.
|
|
||
|
|||
“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”
Copyright - © 2004 - 2019 - All Rights Reserved.