ID: 14817 Updated by: mfischer Reported By: [EMAIL PROTECTED] 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] [EMAIL PROTECTED] 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><list> <item>first</item> <item>second</item> </list></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 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]