|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-01-02 21:40 UTC] mfischer@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 18:00:01 2025 UTC |
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