3 * @brief This class contain functions to work with XML data
7 function from_array($array, &$xml) {
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;
17 return $dom->saveXML();
21 foreach($array as $key => $value) {
22 if (!is_array($value) AND !is_numeric($key))
23 $xml->addChild($key, $value);
24 elseif (is_array($value))
25 self::from_array($value, $xml->addChild($key));
29 function copy(&$source, &$target, $elementname) {
30 if (count($source->children()) == 0)
31 $target->addChild($elementname, $source);
33 $child = $target->addChild($elementname);
34 foreach ($source->children() AS $childfield => $childentry)
35 self::copy($childentry, $child, $childfield);