Xml
in package
XML class.
Tags
Table of Contents
Methods
- fromArray() : mixed
- Convert array to XML.
Methods
fromArray()
Convert array to XML.
public
fromArray(array<string|int, mixed> $array, SimpleXMLElement &$SimpleXml) : mixed
Usage:
// initialize the class.
$SimpleXml = new \SimpleXMLElement('<?xml version="1.0"?><data></data>');
$Xml = new \Rdb\System\Libraries\Xml();
$Xml->fromArray(array('key1' => 'val1', 'key2_array' => array('k2.1' => 'v2.1', 'k2.2' => 'v2.2')), $SimpleXml);
// then generate XML content.
$content = $SimpleXml->asXML();
// or write out as XML file.
$content = $SimpleXml->asXml('xmlfile.xml');
Parameters
- $array : array<string|int, mixed>
- $SimpleXml : SimpleXMLElement