PHP Classes

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    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 264 This week: 1All time: 7,773 This week: 560Up
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
Age: 38
All time rank: 3931112 in Russian Federation Russian Federation
Week rank: 411 Up22 in Russian Federation Russian Federation Up

  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:264
This week:1
All time:7,773
This week:560Up