How to access an XML document in PHP

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.

Oracle suit vs. Google unlikely to prompt Java forking, expert says
InfoWorld - Oracle's lawsuit against Google over Java patents could alienate some people in the Java space, but the litigation is not likely to prompt a forking of the Java platform itself, the founder of the popular Spring Framework for Java development said on Wednesday.

WREA Updates Enterprise Carbon Accounting Package, Claims Web Services Associated With Spreadsheet Ease Carbon ...
WREA announced an updated release to EMSPRO, which it is marketing to large energy users in the industrial sector. A leading expert on renewable energy, Mr. Scott Foster, CEO at WREA also said that careful, proper and efficient use of spreadsheets actually helps with gathering, processing and reporting of data.

Reed's, Inc. Launches Swing-Top Bottles From U.S. Factory
Company Becomes Only Bottling Plant in North America Tooled to Run Swing-Top Bottles

Telcom Industry Standard Small Exchange Carrier Access Billing Support Now Available with New Lymeware SECAB Viewer ...
The billing standard used by most smaller carriers, CLECs, and companies is now supported by the SECAB Viewer product.



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?