Zend - The PHP Company




XML

Add Code


phpDOM  

Type: class library
Added by: dglachs
Entered: 22/02/2001
Last modified: 02/12/2000
Rating: **** (6 votes)
Views: 14198

phpDOM is a class library for creating, extending and manipulating XML documents. It is based on the DOM/XML library of PHP 4.x. It acts as a wrapper to the functions provided by the DOM/XML library. It can be easily extended to reflect your needs and to create specific documents.

phpDOM includes two packages: phpDOM for pure XML, and phpDOM.XHTML for well-formed XHTML documents. These two packages can be used as examples of how to extend the base classes.

phpDOM "tries" to cover the W3C DOM specification and offers a similar syntax to all functions like the W3C specifaction. Since the library depends on the DOM/XML library it is currently not possible to provide all functions of the W3C DOM API, but it provides very good functionality to maintain XML documents as well as XHTML documents.

The code below is just a sample of how the library works, please refer to the "Example-Page" to get the entire library!



<?php
   
/* Include the phpDOM - library */
    
define"PHPDOM_INCLUDE_DIR"">>your path here<<" );
    include( 
PHPDOM_INCLUDE_DIR "domxml_document.php" );

    
/* Use the Library */
    
$doc    = new Document;
    
/* Use the XML file from sample4! */
    
$doc->createFromFile"domxml_sample4.xml" );
    
/* Getting the xpath context */
    
$xpath $doc->getXPathContext();
    
/* Retrieving a NodeList of elements with the given id */
    
$nodes $xpath->evaluate"//child::*[@id="HTML"]" );
    if ( 
$nodes->getLength( ) > ) {
        
$term $nodes->item);
        
$term->setNodeValue(  strtoupper$term->getNodeValue(  ) ) ) ;
    }
    
/* Printing the Document */
    
$doc->printDocument();
?>


Usage Example


See the example


Rate This Script





Search



This Category All Categories