public function addChild($name, $value = null) { if ($name instanceof XmlElementInterface) { $value = $name; $name = $value->getName(); } $coreElement = $this->elem->addChild($name); $element = new XmlElement($coreElement); if ($value instanceof XmlElementInterface) { foreach ($value->attributes() as $k => $v) { $element->attributes()->set($k, $v); } foreach ($value->children() as $child) { $element->addChild($child); } if ($value->text()) { $element->setText($value->text()); } $value->_swapoutInternal($coreElement); } else { $element->setText($value); } return $element; }
public function add($name, $value = null) { $parentElements = $this->elem->xpath('..'); $element = new XmlElement($parentElements[0]); return $element->addChild($name, $value); }
private function wrap($element) { $rootElement = new XmlElement(new \SimpleXMLElement('<routes />')); $rootElement->addChild($element); return $rootElement; }