Bug #14817 Updated: Feature: copying/paste nodes to each other

From: Date: Thu, 03 Jan 2002 02:40:33 +0000
Subject: Bug #14817 Updated: Feature: copying/paste nodes to each other
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-75732@lists.php.net to get a copy of this message
ID: 14817 Updated by: mfischer Reported By: r.klinkenberg@student.utwente.nl Old Status: Open Status: Bogus Bug Type: DOM XML related Operating System: PHP Version: 4.1.1 New Comment: Thats the (intended) behaviour of libxml2 and there's little PHP can do about it. And libxml2 certainly is not designed to handle the way you like to add xml data to your document. You'll have to use the native domxml function PHP provides to construct your XML. Previous Comments: ------------------------------------------------------------------------ [2002-01-02 21:34:58] r.klinkenberg@student.utwente.nl Currently I'm building system that stores xml data in a database. When I get this data out of m database and try to put it into a node, all the xml inside is escaped. For example: ----------------------------------------------------------- $xml = '<list> <item>first</item> <item>second</item> </list>'; $D_doc = new_xmldoc("1.0"); $D_root = $D_doc->add_root('page'); $D_node = $D_root->new_child('posting', $xml); Header('Content-type: text/xml'); echo $D_doc->dumpmem(); ----------------------------------------------------------- Will output the following data: ----------------------------------------------------------- <?xml version="1.0"?> <page><posting>&lt;list&gt; &lt;item&gt;first&lt;/item&gt; &lt;item&gt;second&lt;/item&gt; &lt;/list&gt;</posting></page> ----------------------------------------------------------- Often that is not desired. Therefore I hoped it should be possible to 'copy/paste' dom objects. If that would be possible, I could do something like this: Example: ----------------------------------------------------------- $xml = '<list> <item>first</item> <item>second</item> </list>'; $D_doc = new_xmldoc("1.0"); $D_root = $D_doc->add_root('page'); // Create DOM object from the data $D_posting = xmldoc('<?xml version="1.0"?><posting>' . $xml . '</posting>'); // Paste the root of $D_posting to the first DOM document $D_node = $D_root->add_node($D_posting); Header('Content-type: text/xml'); echo $D_doc->dumpmem(); ----------------------------------------------------------- What should output: ----------------------------------------------------------- <?xml version="1.0" ?> <page> <posting> <list> <item>first</item> <item>second</item> </list> </posting> </page> ----------------------------------------------------------- Currently I'm using a xmltree() to make a DOM document from $xml. The result from xmltree() is that recursively walked through and the nodes that are found are added to the first DOM document. Hopefully there is a way to implement the direct copying of dom object, like eg. in Java. -- Rense ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=14817&edit=1

« previous php.dev (#75732) next »