Reputation: 13920
I need something like InnerHTML
of a node, it is very simple, and perhaps I am not knowing how to use childNodes
... I need some function that receives a node (DOMElement or DOMNode) with a root, and outputs the (DOM-XML object or XML-string value) filling. So, it is a "DOMnode node-root remover".
Example of workaround with PHP and regular expression:
function xsl_getInner($ele) {
// not works with $ele->childNodes
$xml = $ele->ownerDocument->saveXML($ele);
return preg_replace('/^<([a-zA-Z0-9_\-])\s?[^>]*>(.*?)</\1>$/s','$2',$xml);
}
Related question: How to change root of a node with DomDocument methods?
Upvotes: 1
Views: 72