https://github.com/xp-framework/xml
XML APIs for the XP Framework
https://github.com/xp-framework/xml
php xml xp-framework
Last synced: 2 months ago
JSON representation
XML APIs for the XP Framework
- Host: GitHub
- URL: https://github.com/xp-framework/xml
- Owner: xp-framework
- Created: 2013-11-12T16:21:19.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-03-29T09:22:55.000Z (about 1 year ago)
- Last Synced: 2024-04-29T13:22:02.044Z (about 1 year ago)
- Topics: php, xml, xp-framework
- Language: PHP
- Size: 3.32 MB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
Awesome Lists containing this project
README
XML APIs for the XP Framework
=============================[](https://github.com/xp-framework/xml/actions)
[](https://github.com/xp-framework/core)
[](https://github.com/xp-framework/core/blob/master/LICENCE.md)
[](http://php.net/)
[](http://php.net/)
[](https://packagist.org/packages/xp-framework/xml)The xml package provides APIs to handle XML.
XML data
--------
Most of the time, XML is used to hold data. In this case, a fully blown
DOM api is too much overhead to work with the data. This is where the
xml.Tree class comes in.This example will print out a nicely formatted XML document:
```php
use xml\{Tree, Node};$t= new Tree('customer');
$t->root()->setAttribute('id', '6100');
$t->addChild(new Node('name', 'Timm Übercoder'));
$t->addChild(new Node('email', '[email protected]'));echo $t->getSource(INDENT_DEFAULT);
```XSL Transformation
------------------
The DomXSLProcessor class uses LibXSLT and thus supports EXSLT features
like user functions, callbacks, string functions, dynamic evaluation and
more.A simple example:
```php
use xml\DomXSLProcessor;
use xml\TransformerException;
use util\cmd\Console;$proc= new DomXSLProcessor();
$proc->setXSLFile('test.xsl');
$proc->setXMLFile('test.xml');try {
$proc->run();
} catch (TransformerException $e) {
// Handle
}Console::writeLine($proc->output());
```XPath queries
-------------```php
use xml\XPath;
use util\cmd\Console;$xml= '
Open a file
';Console::writeLine((new XPath($xml))->query('/dialog/buttons/button/@name')));
```