Exforsys

Home arrow Reviews arrow PHP Oracle Training Tutorials

XML Processing in PHP and Oracle Applications

Author : Exforsys Inc.     Published on: 19th Apr 2008    |   Last Updated on: 21st Apr 2008

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.

Ads

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.

Ads

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.



 
This tutorial is part of a PHP Oracle Training Tutorials tutorial series. Read it from the beginning and learn yourself.

PHP Oracle Training Tutorials

 

Comments