Re: XML_Tree and mixed content tags

From: Date: Mon, 14 Apr 2003 23:26:37 +0000
Subject: Re: XML_Tree and mixed content tags
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-15173@lists.php.net to get a copy of this message
I get the feeling that the way that the XML_Tree does things at the moment is correct because if you look at a XHTML document, which is XML, you can do this sort of thing : <p>This is the start of the para, <b>followed by some bold</b>, and now we finish.</p> And if you are parsing this contents you most probably need to know that the bold tag comes after the first section of text and before the last section. You are able to ascertain the text nodes by the fact that the name is a blank string, so you could just loop over the children of the node looking for blank names and appending their contents to your own variable. cheers BCR Richard Heyes wrote:
When XML_Tree parse the following XML: <tree>4 <node></node> </tree> It produces a single root node (<tree>) but with two child nodes instead
of
one. The first child node is for the "4" content, and the second for the <node> tag. Is this correct? IMO there should only be only a single child node, with the content being assigned to the root <tree> node.
And here's a diff in which would fix the issue: Index: Tree.php =================================================================== RCS file: /repository/pear/XML_Tree/Tree.php,v retrieving revision 1.23 diff -b -u -r1.23 Tree.php
--- Tree.php    4 Jan 2003 11:56:34 -0000       1.23
+++ Tree.php    14 Apr 2003 10:45:57 -0000
@@ -235,7 +235,7 @@
             if (!empty($this->cdata)) {
                 $parent_id = 'obj' . ($this->i - 1);
                 $parent    =& $this->$parent_id;
-                $parent->children[] = &new XML_Tree_Node(null,
$this->cdata);
+                $parent->content = $this->cdata;
             }
             $obj_id = 'obj' . $this->i++;
             $this->$obj_id = &new XML_Tree_Node($elem, null, $attribs);
-- Richard Heyes V-webmail - http://www.v-webmail.org


« previous php.pear.dev (#15173) next »