ask / xml-builder
Easy PHP XML Builder
Installs: 5 603
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: 4.3.*
This package is auto-updated.
Last update: 2024-10-29 04:19:05 UTC
README
Generate XML
<?php $xmlBuilder = XmlBuilder::create(); $xmlBuilder ->element('root') ->element('ns:element', 'value', 'http://ns/ns') ->attr('ns:attr1', 'value1', 'http://ns/ns') ->attr('attr2', 'value2') ->end() ->end() ; echo $xmlBuilder->getXml(true);
Result:
<?xml version="1.0" encoding="utf-8"?> <root> <ns:element xmlns:ns="http://ns/ns" ns:attr1="value1" attr2="value2">value</ns:element> </root>
Reference
<?php $xmlBuilder = XmlBuilder::create(); $xmlBuilder ->element('root') ->element('user') ->element('addresses')->reference($addresses)->end() ->end() ->end() ; $addresses->element('address', 'value1')->end(); $addresses->element('address', 'value2')->end(); echo $xmlBuilder->getXml(true);
Result:
<?xml version="1.0" encoding="utf-8"?> <root> <user> <addresses> <address>value1</address> <address>value2</address> </addresses> </user> </root>