DomQuery::arrayToXml();

This methods will take the provided array and transform it into a well-formed into a DOMDocument.

 $array = array
 (
     'root' => array
     (
         'foo' => 'foo',
         'bar' => 'bar',
         'baz' => 'baz',
         'field[0]' => 'field one value',
         'field[1]' => 'field two value',
         'field[2]' => 'field three value'
     )
 );
 $DomQuery = new DomQuery;
 $DomQuery->arrayToXml($array);
 header('Content-Type: text/xml');
 echo $DomQuery->load($array)->dump(DUMP_AS_STRING);

Definition:

public function arrayToXml(array &$records = array(), DOMElement &$Node = null)

Parameters:

Name Type Description
$source String The XML source document.
$path_from String XPath expression to locate elements to merge.

Recent Discussions

No discussions yet!