PHP Classes
elePHPant
Icontem

amba XML document: Extend the DOM XML classes

Recommend this page to a friend!
  Info   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2010-07-26 (6 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 254 All time: 7,361 This week: 1,050Up
Version License PHP version Categories
amba-xml-document 3.2BSD License5.3XML, PHP 5
Description Author

This package extends the DOM XML classes to provide additional functionality.

The DOM Document extension class can return the document root element, add a new node to the end of the document, select nodes that match a XPath expression, call a function for a list of elements and transform a document using XSL.

The DOM element extension class can get XML for the owner document, get the node XPath, get child nodes, select child nodes that match a XPath expression, get the parent and sibling nodes, get and set attributes by name, copy attributes, add child nodes and character data, import and export nodes to and from another document, set and get the inner XML of a node, call a function for nodes that map a XPath expression, etc..

Standard DOMDocument has rich functionality, but it is not handy enough. XMLDocument is extension of standard PHP DOMDocument and DOMElement.


This project contains two classes for easy create, navigate and process XML documents.

Main features is:

* SelectSingleNode and SelectNodes - node related functions works like same functions in C#.
* Inner XML getting/setting - easy and in one line.
* Chain style to create new node sets.
* Functions for frequently used actions: copy attributes, delete all childs etc.

Usage sample:

$doc = new XMLDocument("<Users/>");
$doc->getRoot()->addNode('User')
->setAttribute('Active', 'true')
->addNodeWithCData('Name', 'John')
->getParent()->getParent()
->addNode('User')
->setInnerXML('<Name><![CDATA[Peter]]></Name>');
echo $doc->saveXML();

Result:

<Users>
<User Active="true">
<Name><![CDATA[John]]></Name>
</User>
<User>
<Name><![CDATA[Peter]]></Name>
</User>
</Users>

See Samples for more details.

Picture of Alexey V Ryazhskikh
Name: Alexey V Ryazhskikh <contact>
Classes: 1 package by
Country: Russian Federation Russian Federation

  Files folder image Files  
File Role Description
Plain text file XMLDocument.php Class Extends DOMDocument
Accessible without login Plain text file XMLDocumentTest.php Test Tests for XMLDocument and XMLElement
Plain text file XMLElement.php Class Extends DOMElement

 Version Control Unique User Downloads Download Rankings  
 0%
Total:254
This week:0
All time:7,361
This week:1,050Up