Using DOM, XML and PHP to parse XML

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.

posted by Will Senn on Wed 30th Nov 2005 19:03 UTC (OS News)
This latest installment in the Core series from Prentice Hall PTR is a welcome arrival to the PHP/MySQL space. It is jam packed with useful information. At a little over 850 pages, this volume contains information on nearly every topic of interest in both the PHP and MySQL subject areas.

Once Nearly Invisible To Search Engines, Flash Files Can Now Be Found And Indexed (TechCrunch)
For most people on the Web, if Google or Yahoo cannot find something, it doesn't exist. That has been one of the biggest drawbacks to creating a Website or application that displays itself as a Flash (SWF) file. Search engines could see the file, but they could not see what was in it. [...]

Linked by Thom Holwerda on Thu 5th Oct 2006 20:33 UTC, submitted by anonymous (OS News)
These easy to understand XForms tips show you how to get the most out of your XForms. In this XForms and Perl tip , you'll learn how to submit an XForms form using POST to a Perl script, and capture the data for later use.



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.

_______________________________________

Recommended XML Books

cover
cover
cover
cover
cover
cover







 

 

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!


New XML Books Titles - Best Seller's @ Amazon.com

Visit XML Training Material Guide Homepage

Technology helps engage students - how do classroom instruction and social dynamics change when the classroom is completely dependant on modern technology?

Dallas Web Design- local Dallas web design firm offers site design and backend system development