Reviews
PHP Oracle Training TutorialsXML 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.
PHP Oracle Training Tutorials
- PHP Oracle Web Development
- XML Processing in PHP and Oracle Applications
- Creating XML with the DOM PHP Extension
- Querying a DOM Document with XPath
- Transforming and Processing XML with XSLT
- Performing XML Processing inside the Database
- Moving All the XML Processing into the Database
- Performing XSLT Transformations inside the Database
- Using Oracle Database for Storing, Modifying, and Retrieving XML Data
- Using XMLType for Handling XML Data in the Database
- Using XML Schemas
- Retrieving XML Data
- Using XMLType Views
- Performing DML Operations on XML Schema Based XMLType Views
- Using Oracle XML DB Repository
- Accessing Repository Resources with SQL
- Taking Advantage of Standard Internet Protocols
- Querying Data with Oracle XQuery
- Breaking up XML into Relational Data







