From:             [EMAIL PROTECTED]
Operating system: 
PHP version:      4.1.1
PHP Bug Type:     DOM XML related
Bug description:  Feature: copying/paste nodes to each other

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 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]

Reply via email to