protected function buildElement($node)
{
$element = new TXmlElement($node->tagName);
$element->setValue($node->nodeValue);
foreach ($node->attributes as $name => $attr) {
$element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name, $attr->value);
}
foreach ($node->childNodes as $child) {
if ($child instanceof \DOMElement) {
$element->getElements()->add($this->buildElement($child));
}
}
return $element;
}