There two
common ways to access an xml document using PHP. One is the usual Document
Object Model and the other is by using the SAX parser that comes with
all the installation of PHP.
_______________________________________________
Using the
Document Object Model is the common way used by many developers to access
the xml documents. You might have worked with the DOM in other languages
too. The steps are the same.
The first
step is to create a new document object using the command, new DOMDocument();
and the next step is to load the xml file into that object. For this
you can use the command, load('xmlfilename.xml').
After this
is done you can navigate through the xml document using the functions
like getElementsByTagName. By using this function you can store all
the nodes in a particular array and then use the array's item(n)->nodeValue
to get the values of the nodes, where n is the node number.
You can
also access the xml document using the SAX parser that comes with the
installation of PHP. It is lightweight and that is the advantage of
using it. Moreover it can also be used for large xml files.