Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.0.0RC3

Bug #492 character data content at the end of root element is ignored
Submitted: 2003-12-24 22:44 UTC
From: chris_se at gmx dot net Assigned: davey
Status: Closed Package: XML_Tree
PHP Version: Irrelevant OS: All
Roadmaps: (Not assigned)    
Subscription  


 [2003-12-24 22:44 UTC] chris_se at gmx dot net
Description: ------------ If you have an XML-File with character data at the end of the root element, this character data will be ignored. Please note that this will not occur, if there is any other xml element *after* the character data. It only occurs, if the character data is at the end of the root element. Version: $Id: Tree.php,v 1.31 2003/09/18 10:51:34 cox Exp $ The following patch will solve the problem: --- Tree-old.php 2003-12-24 23:39:01.000000000 +0100 +++ Tree.php 2003-12-24 23:39:14.000000000 +0100 @@ -303,6 +303,15 @@ $parent =& $this->$parent_id; // attach the node to its parent node children array $parent->children[] = $node; + } else { + $node =& $this->obj1; + if (count($node->children) > 0) { + if (trim($this->cdata)) { + $node->children[] = &new XML_Tree_Node(null, $this->cdata); + } + } else { + $node->setContent($this->cdata); + } } $this->cdata = null; return null; Reproduce code: --------------- parser.php: <?php require 'XML/Tree.php'; $tree = new XML_Tree ('data.xml'); $tree->getTreeFromFile (); $tree->dump (); ?> data.xml: <?xml version="1.0" encoding="iso-8859-1"?> <root> content </root> Expected result: ---------------- <?xml version="1.0"?> <root>content</root> Actual result: -------------- <?xml version="1.0"?> <root></root>

Comments

 [2004-05-19 11:31 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2007-09-26 15:39 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!