Working with XML and PHPYou 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.
|
|
||
|
|||
“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”
Copyright - © 2004 - 2019 - All Rights Reserved.