note 18929 added to ref.domxml
| From: | apinstein at mac dot NOSPAM dot com | Date: | Sun, 10 Feb 2002 07:06:59 +0000 |
| Subject: | note 18929 added to ref.domxml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26437@lists.php.net to get a copy of this message | ||
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;
}
}
}
--
http://www.php.net/manual/en/ref.domxml.php
http://master.php.net/manage/user-notes.php?action=edit+18929
http://master.php.net/manage/user-notes.php?action=delete+18929
http://master.php.net/manage/user-notes.php?action=reject+18929