note 18929 deleted from ref.domxml by sniper
| From: | sniper@php.net | Date: | Mon, 03 Nov 2003 15:47:58 +0000 |
| Subject: | note 18929 deleted from ref.domxml by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-59715@lists.php.net to get a copy of this message | ||
Note Submitter: apinstein@mac.NOSPAM.com
----
Hopefully this will help anyone who had as much trouble as I have using domxml across different PHP
versions...
I am using 4.1.1 now, with libxml2-2.4.13.
It seems that the way the XML tree is represented has changed from 4.06/libxml2-2.3.14 to use
multple node types.
I had a lot of trouble figuring out how to get to the TAGNAME and CONTENT data for my XML tree...
but I figured it out and wanted to share:
function getNodeContent($name) {
$child_a = domxml_children(domxml_root($doc));
foreach ($child_a as $node) {
if ($node->tagname() == $name) {
// the CONTENT of a node is in the content field of a
// CHILD node of the tag name.
// <NODE>DATA</NODE> is actually a NODE element
// object with a TEXT element object as its only child.
// THe child TEXT element has the content field with
// the actual content.
// it helps a LOT to do a print_r(xmltree($xml)) and
// look at this as HTML SOURCE because it's nicely indented
$content_a = domxml_children($node);
return $content_a[0]->content;
}
}
}