public function Twig_Node::toXml in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/twig/twig/lib/Twig/Node.php \Twig_Node::toXml()
Deprecated
since 1.16.1 (to be removed in 2.0)
File
- vendor/
twig/ twig/ lib/ Twig/ Node.php, line 75
Class
- Twig_Node
- Represents a node in the AST.
Code
public function toXml($asDom = false) {
@trigger_error(sprintf('%s is deprecated.', __METHOD__), E_USER_DEPRECATED);
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->formatOutput = true;
$dom
->appendChild($xml = $dom
->createElement('twig'));
$xml
->appendChild($node = $dom
->createElement('node'));
$node
->setAttribute('class', get_class($this));
foreach ($this->attributes as $name => $value) {
$node
->appendChild($attribute = $dom
->createElement('attribute'));
$attribute
->setAttribute('name', $name);
$attribute
->appendChild($dom
->createTextNode($value));
}
foreach ($this->nodes as $name => $n) {
if (null === $n) {
continue;
}
$child = $n
->toXml(true)
->getElementsByTagName('node')
->item(0);
$child = $dom
->importNode($child, true);
$child
->setAttribute('name', $name);
$node
->appendChild($child);
}
return $asDom ? $dom : $dom
->saveXML();
}