PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » XML » XML_sql2xml » Bug #1110

addXmlString throws warning when calling append_child()

Details

Submitted2004-04-01 00:10 UTC
Frompear dot php dot net at brianmaddy dot com
Assignedchregu
StatusClosed
PackageXML_sql2xml
PHP Version4.3.2
OSUnix
Roadmaps(Not assigned)

Comments

[2004-04-01 00:10 UTC] pear dot php dot net at brianmaddy dot com

Description:
------------
As of PHP 4.3.2, the append_child function works as specified in the DOM Level 2 specification (http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-184E7107). This causes the following error in XML_sql2xml::addXmlString and XML_sql2xml::add functions (probably some other add* functions also):

Warning: append_child(): Can't append node, which is in a different document than the parent node...

I believe the origional author meant to work around this by replacing a comment created a few lines earlier, but foorgot to finish the implementation. Anyway, here's the patch that got it to work foor me:

--- sql2xml.php.orig Wed Mar 31 18:35:40 2004
+++ sql2xml.php Wed Mar 31 18:37:56 2004
@@ -816,7 +816,7 @@
// if no xpath is given, just take the whole file
if ( (is_null($xpath)))
{
- $newchild->append_child($tmpxml->root());
+ $newchild->replace_node($tmpxml->root());
}
else
{
@@ -824,7 +824,7 @@
$xnode = xpath_eval($xctx,$xpath);
foreach ($xnode->nodeset as $node)
{
- $newchild->append_child($node);
+ $newchild->replace_node($node);
}
}

If one of the developers could add this to the next version, it would be appreciated!

Thanks!
Brian

Reproduce code:
---------------
$sqlXml->addXmlString('<date-today>asdf</date-today>');
echo $sqlXml->getXml();

Expected result:
----------------
<?xml version="1.0" ?>
<root>
<date-today>asdf</date-today>
</root>

Actual result:
--------------
Warning: append_child(): Can't append node, which is in a different document than the parent node...