Append a childelement from a well formed xml string.

@param string $xml a well formed xml string
@access public
@return void
332159
public function appendChildFromXmlString($xml)
    {
        $dom = new \DOMDocument;
        $dom->loadXML($xml);

        $element = simplexml_import_dom($dom);

        $this->appendChildNode($element);
    }
1018382
protected function XMLAppend(\DOMNode &$parent = null, $content = null)
	{
		if (is_null($parent)) {
			$parent = $this->root;
		}
		if (
			is_string($content)
			or is_numeric($content)
			or (is_object($content) and method_exists($content, '__toString'))
		) {
			$parent->appendChild($this->createTextNode("$content"));
		} elseif (
			is_object($content)
			and is_subclass_of($content, '\DOMNode')
		) {
			$parent->appendChild($content);
		} elseif (
			is_array($content)
			or (is_object($content) and $content = get_object_vars($content))
		) {
			array_map(
				function($node, $value) use (&$parent){
					if (is_string($node)) {
						if (substr($node, 0, 1) === '@') {
							$parent->setAttribute(substr($node, 1), $value);
						} else {
							$node = $parent->appendChild($this->createElement($node));
							if (is_string($value)) {
								$this->XMLAppend(
									$node,
									$this->createTextNode($value)
								);
							} else {
								$this->XMLAppend($node, $value);
							}
						}
					} else {
						$this->XMLAppend($parent, $value);
					}
				},
				array_keys($content),
				array_values($content)
			);
		} elseif (is_bool($content)) {
			$parent->appendChild(
				$this->createTextNode($content ? 'true' : 'false')
			);
		} else {
			throw new \InvalidArgumentException(
				sprintf(
					'Unable to append unknown content [%s] to %s',
					get_class($content),
					get_class($this)
				)
			);
		}

		return $this;
	}
795612
public static function formXml($xml, $file)
    {
        $xml = simplexml_load_string($xml);
        /** @var  $dataArray \SimpleXMLElement[] */
        $dataArray = $xml->attributes();

        $dataFileInfo = new DataFileInfo();
        if (isset($dataArray['Id'])) {
            $dataFileInfo->setId($dataArray['Id']->__toString());
        }
        if (isset($dataArray['Filename'])) {
            $dataFileInfo->setFilename($dataArray['Filename']->__toString());
        }
        if (isset($dataArray['ContentType'])) {
            $dataFileInfo->setContentType($dataArray['ContentType']->__toString());
        }
        if (isset($dataArray['MimeType'])) {
            $dataFileInfo->setMimeType($dataArray['MimeType']->__toString());
        }
        if (isset($dataArray['Size'])) {
            $dataFileInfo->setSize($dataArray['Size']->__toString());
        }
        if (isset($dataArray['DigestType'])) {
            $dataFileInfo->setDigestType($dataArray['DigestType']->__toString());
        }
        if (isset($dataArray['DigestValue'])) {
            $dataFileInfo->setDigestValue($dataArray['DigestValue']->__toString());
        }
        if (isset($dataArray['DfData'])) {
            $dataFileInfo->setDfData($dataArray['DfData']->__toString());
        } elseif (file_exists($file)) {
            $dataFileInfo->setDfData(base64_encode(file_get_contents($file)));
        }

        // TODO: validate data

        return $dataFileInfo;
    }
1013497
protected function setChilds(SimpleXMLElement $element)
    {
        parent::setChilds($element);
        
        $this->putChildsAsCDATAFromList($element, array(
            'nb_site_target_attributes' => 'attributes'
        ), false);
    }
338106
public function FromXML($xml)
	{
		$sxo = new SimpleXMLElement($xml);
		
		if($sxo->encoding == "base64")
		{
			$this->Data = base64_decode($sxo->data);
		}
		else
		{
			$this->Data = $sxo->data;
		}
		
		$this->Name = $attachment->name;
		$this->Type = $attachment->type;
		$this->Size = $attachment->size;
		$this->Extension = $attachment->extension;
	}
371046
public function appendChild( $child = null /* .. AbstractElement $element .. */ ) {
		$arg_list = func_get_args();

		foreach( $arg_list as $arg ) {
			if( $arg instanceof AbstractElement ) {
				$inject = $arg;
			} elseif( is_scalar($arg) ) {
				$inject = new Text($arg);
			} else {
				throw new \InvalidArgumentException;
			}

			$inject->_setParent($this);
			$this->childElements[] = $inject;
		}

		return $this;
	}
1264218
public function addElement($element)
    {
        if ($this->processing === 'B') {
            $this->bodyElements[] = $element;
        } elseif ($this->processing === 'H') {
            $this->headerElements[] = $element;
        } elseif ($this->processing === 'F') {
            $this->footerElements[] = $element;
        }
    }
599138
public function addChild($child)
    {
        $class = $this->getShortName($child);

        // Only add child if it's an known element.
        if (array_key_exists($class, $this->elements)) {
            // If we can expect more, add it to an array.
            //if (substr($this->elements[$class], -6) == '_MULTI') {
            if (in_array($this->elements[$class], [self::REQUIRED_MULTI, self::OPTIONAL_MULTI])) {
                $this->{$class}[] = $child;
            } else {
                $this->{$class} = $child;
            }
        } else {
            die($this->getShortName(get_called_class()) .": {$class} is not allowed as a child element.");
        }
    }
41424
protected function loadXML($xml)
	{
		$this->checkUnsupported($xml);

		// Activate small nodes allocation and relax LibXML's hardcoded limits if applicable. Limits
		// on tags can be set during configuration
		$flags = (LIBXML_VERSION >= 20700) ? LIBXML_COMPACT | LIBXML_PARSEHUGE : 0;

		$useErrors = libxml_use_internal_errors(true);
		$dom       = new DOMDocument;
		$success   = $dom->loadXML($xml, $flags);
		libxml_use_internal_errors($useErrors);

		if (!$success)
		{
			throw new InvalidArgumentException('Cannot load XML: ' . libxml_get_last_error()->message);
		}

		return $dom;
	}
21317
protected function addElement(\DomDocument $document, \DOMElement $rootElement, NodeInterface $node) : void
    {
        $title = htmlspecialchars($node->getTitle());
        $element = $document->createElement(static::NODE_NAME, $title);
        $rootElement->appendChild($element);
    }
582789
protected function _appendDataToNode($addCdata, Xml $xml, $key, $value)
    {
        if ($addCdata) {
            $cdata      = $xml->createCDATASection($value);
            $element    = $xml->createElement(
                $this->_integerToStringKey($key)
            );
            $element->appendChild($cdata);
        } else {
            $element = $xml->createElement(
                $this->_integerToStringKey($key),
                $value
            );
        }

        return $element;
    }
574278
private function createRelationsElement($xml)
    {
        $relations = $xml->createElement('relations');

        foreach ($this->relations as $type => $rr) {
            foreach ($rr as $relation) {
                $relations->appendChild($this->createRelationElement($xml, $type, $relation));
            }
        }

        return $relations;
    }
933753
function prepend (el, child) {
  if (el.firstChild) {
    el.insertBefore(child, el.firstChild)
  } else {
    el.appendChild(child)
  }
}
295391
public function parseXml($node)
    {
        foreach ($node->childNodes as $item) {
            if ($item->nodeName != "#text") {
                $this->set( $item->nodeName, $item->nodeValue);
            }
        }

    }
699830
public function addElement($elementName, $content, $attributes = null)
    {
        $this->elements[$elementName]['name'] = $elementName;
        $this->elements[$elementName]['content'] = $content;
        $this->elements[$elementName]['attributes'] = $attributes;
    }
393724
public void append(XMLString s) {
        append(s.ch, s.offset, s.length);
    }
1276236
private function xmlToElements($xml)
    {
        //====================================================================//
        // Convert XML to Object Recursively
        try {
            $result = simplexml_load_string($xml, "SimpleXMLElement", LIBXML_NOERROR);
        } catch (Exception $ex) {
            $this->fault = $ex->getMessage();

            return false;
        }

        return $result;
    }