3 * @brief This class contain functions to work with XML data
7 function from_array($array, &$xml, $remove_header = false) {
9 if (!is_object($xml)) {
10 foreach($array as $key => $value) {
11 $root = new SimpleXMLElement("<".$key."/>");
12 self::from_array($value, $root);
14 $dom = dom_import_simplexml($root)->ownerDocument;
15 $dom->formatOutput = true;
18 $xml_text = $dom->saveXML();
21 $xml_text = trim(substr($xml_text, 21));
27 foreach($array as $key => $value) {
28 if (!is_array($value) AND !is_numeric($key))
29 $xml->addChild($key, xmlify($value));
30 elseif (is_array($value))
31 self::from_array($value, $xml->addChild($key));
35 function copy(&$source, &$target, $elementname) {
36 if (count($source->children()) == 0)
37 $target->addChild($elementname, $source);
39 $child = $target->addChild($elementname);
40 foreach ($source->children() AS $childfield => $childentry)
41 self::copy($childentry, $child, $childfield);