note 52865 deleted from function.dom-domdocument-savexml by bjori
| From: | bjori@php.net | Date: | Mon, 27 Mar 2006 00:26:26 +0000 |
| Subject: | note 52865 deleted from function.dom-domdocument-savexml by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-106692@lists.php.net to get a copy of this message | ||
Note Submitter: joe at fakeemail dot com
----
Say you want to put some XHTML inside an XML node and later extract it for output to the browser.
For example:
"<friend>Joanne <a href='joanne.com'>visit
website</a></friend>"
You need an innerXML function, similar to the Javascript innerHTML. It might look like this:
function innerXML(&$node){
if(!$node) return false;
$document = $node->ownerDocument;
$nodeAsString = $document->saveXML($node);
preg_match('!\<.*?\>(.*)\</.*?\>!',$nodeAsString,$match);
return $match[1];
}