XML documents
can be parsed using DOM and PHP easily. You can also use XPath for more
precise navigation and retrieval of the contents of the nodes.
_______________________________________________
To parse
an XML document, first you have to create a document object to load
the XML file in it. Once you have loaded the document, you can use the
getElementsByTagName method to get all the elements that have a particular
node name. Using the foreach loop you can print all the elements that
you have retrieved.
If you
are going to use XPath then you can make more precise queries on the
XML document. for example if you want to query all the authors available
in your XML file, you could use something like, "/books/book/author"
in your XPath query.
Suppose
you want only the author name of the book in the 5th position then you
could use a query like, "/books/book[position()=5]/author".
A good knowledge on using XPath will help you a lot in navigating an
XML document.