Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

18,510 Commits

Repository files navigation

XML APIs for the XP Framework

Build status on GitHubXP Framework ModuleBSD LicenceRequires PHP 7.0+Supports PHP 8.0+Latest Stable Version

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:

usexml\{Tree, Node};
$t= newTree('customer');
$t->root()->setAttribute('id', '6100');
$t->addChild(newNode('name', 'Timm Übercoder'));
$t->addChild(newNode('email', 'uebercoder@example.com'));
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:

usexml\DomXSLProcessor;
usexml\TransformerException;
useutil\cmd\Console;
$proc= newDomXSLProcessor();
$proc->setXSLFile('test.xsl');
$proc->setXMLFile('test.xml');
try {
$proc->run();
} catch (TransformerException$e) {
// Handle
}
Console::writeLine($proc->output());

XPath queries

usexml\XPath;
useutil\cmd\Console;
$xml= '<dialog id="file.open"> <caption>Open a file</caption> <buttons> <button name="ok"/> <button name="cancel"/> </buttons></dialog>';
Console::writeLine((newXPath($xml))->query('/dialog/buttons/button/@name')));

About

XML APIs for the XP Framework

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages