public function LingotekXMLElement::addChildXML in Lingotek Translation 7.7
Add a SimpleXMLElement object as a child
Parameters
SimpleXMLElement $child:
type $element_name:
File
- lib/
Drupal/ lingotek/ LingotekXMLElement.php, line 23 - Defines LingotekXMLElement
Class
- LingotekXMLElement
- An extension of SimpleXMLElement to add CDATA
Code
public function addChildXML(SimpleXMLElement $child, $element_name = NULL) {
if (!$element_name) {
$element_name = $child
->getName();
}
$this_child = $this
->addChild($element_name);
$to_dom = dom_import_simplexml($this_child);
$from_dom = dom_import_simplexml($child);
foreach ($from_dom->childNodes as $child_element) {
$to_dom
->appendChild($to_dom->ownerDocument
->importNode($child_element, TRUE));
}
}