Exforsys.com
 
Home Tutorials PHP Oracle
 

XML Processing in PHP and Oracle Applications

 

Processing XML in PHP/Oracle Applications

As mentioned, there are two alternatives when it comes to performing XML processing in your PHP/Oracle application. You can perform any required XML processing using either PHP's XML extensions (or PEAR XML packages) or Oracle's XML features.



In the following sections, you will learn how to construct XML from relational data using the XML capabilities of both PHP and Oracle.


Processing XML Data with PHP

PHP provides three general extensions allowing you to work with XML. These extensions are listed in the following table:


PHP extension Description
XML extension

The XML extension implements the SAX (Simple API for XML) approach to parsing and accessing XML content. The SAX parsing mechanism is memory efficient since it doesn't require the entire XML document to be stored in memory. This makes the SAX approach useful for certain type of operations on XML, for example, searching.


   
DOM extension

The DOM extension provides APIs for working with XML using DOM (Document Object Model). Unlike a SAX parser, a DOM parser builds an in-memory representation of an XML document, which in most cases makes performing modifying and updating operations more efficient.


   
SimpleXML extension

As its name implies, the SimpleXML extension provides the easiest way to work with XML. The SimpleXML approach allows you to access an XML document through its data structure representation and so can be especially useful when you simply need to read XML.


In practice, you should choose the extension that best suits the needs of your applications. For example, the XML extension implementing the SAX model can be very efficient when it comes to parsing large XML documents from which you only want to extract useful information. In contrast, the DOM extension comes in handy when you need to generate XML documents or modify existing ones. With the SimpleXML extension, XML documents are turned into data structures that can be then iterated like regular PHP arrays and objects, thus providing the most natural way for PHP developers to access data.


Since the Document Object Model (DOM) is best used for solving complex tasks, the following sections demonstrate how to use DOM extension APIs to generate, query, and manipulate XML documents in PHP.



NOTE:


Admittedly, the Document Object Model is widely used in web development. Web browsers, for example, use the DOM to represent web pages they display to the users. In Chapter 10 AJAX-Based Applications, you will learn techniques to access and manipulate the DOM tree of a web page sent to the browser by your application, thus allowing you to produce more interactive and responsive PHP/Oracle solutions.



Read Next: Creating XML with the DOM PHP Extension



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2010 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape