vannus Posted June 27, 2009 Share Posted June 27, 2009 <domnode>inside part</domnode> i can get the content of a node easily enough echo $myDOMNode->nodeValue; outputs 'inside part' echo $myDOMNode->textContent; outputs 'inside part' echo $myDOMNode->get_content; outputs 'inside part' how to i get the node itself as text/string? ie. echo $myDOMNode->asText; would output '<domnode>inside part</domnode>' is it even possible??? annoyingly even below hasnt worked for me $doc=new DOMDocument(); $doc->appendChild($doc->importNode($myDOMNode,true)); echo $doc-saveHTML(); i had to import cause $myDOMNode is really an $xpath->query('//domnode')->item(0) result. any help would be appreciated cause this is doing my head in! Jim. Link to comment https://forums.phpfreaks.com/topic/163908-get-domnode-as-text/ Share on other sites More sharing options...
vannus Posted July 8, 2009 Author Share Posted July 8, 2009 annoyingly even below hasnt worked for me $doc=new DOMDocument(); $doc->appendChild($doc->importNode($myDOMNode,true)); echo $doc-saveHTML(); i had to import cause $myDOMNode is really an $xpath->query('//domnode')->item(0) result. just a typo... $doc=new DOMDocument(); $doc->appendChild($doc->importNode($myDOMNode,true)); echo $doc->saveHTML(); although some form of DomNode->getNodeAsText(bool $deep) would be nice... Link to comment https://forums.phpfreaks.com/topic/163908-get-domnode-as-text/#findComment-871401 Share on other sites More sharing options...
ignace Posted July 8, 2009 Share Posted July 8, 2009 print $doc->documentElement->tagName; Link to comment https://forums.phpfreaks.com/topic/163908-get-domnode-as-text/#findComment-871409 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.