mirror of
https://github.com/friendica/friendica
synced 2025-04-21 18:30:11 +00:00
Receiving should be complete, sending partially works
This commit is contained in:
parent
49e8528e52
commit
265af9c99b
2 changed files with 538 additions and 40 deletions
39
include/xml.php
Normal file
39
include/xml.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief This class contain functions to work with XML data
|
||||
*
|
||||
*/
|
||||
class xml {
|
||||
function from_array($array, &$xml) {
|
||||
|
||||
if (!is_object($xml)) {
|
||||
foreach($array as $key => $value) {
|
||||
$root = new SimpleXMLElement("<".$key."/>");
|
||||
self::from_array($value, $root);
|
||||
|
||||
$dom = dom_import_simplexml($root)->ownerDocument;
|
||||
$dom->formatOutput = true;
|
||||
$xml = $dom;
|
||||
return $dom->saveXML();
|
||||
}
|
||||
}
|
||||
|
||||
foreach($array as $key => $value) {
|
||||
if (!is_array($value) AND !is_numeric($key))
|
||||
$xml->addChild($key, $value);
|
||||
elseif (is_array($value))
|
||||
self::from_array($value, $xml->addChild($key));
|
||||
}
|
||||
}
|
||||
|
||||
function copy(&$source, &$target, $elementname) {
|
||||
if (count($source->children()) == 0)
|
||||
$target->addChild($elementname, $source);
|
||||
else {
|
||||
$child = $target->addChild($elementname);
|
||||
foreach ($source->children() AS $childfield => $childentry)
|
||||
self::copy($childentry, $child, $childfield);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue