[Solved] Re: [PHP] DOM: Problem with loadXML(), createProcessingInstruction()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Has anyone found a workaround for this; a workaround the fact that loadXML() completely replaces the existing document structure?

It's amazing what you find out after you've already made yourself look foolish.

$xmlStr = '<root><child_element>blah</child_element></root>';

$doc = new DOMDocument( '1.0', 'UTF-8' );
$docFragment = $doc->createDocumentFragment();
$docFragment->appendXML( $xmlStr ); // Why this isn't called also loadXML()
// I have no idea. It would make sense // that it would be so as to maintain // consistency in names of methods // where it relates to functionality, // particularly when that functionality is // similar across classes.
$doc->appendChild( $doc->createProcessingInstruction( 'blah', 'blah' );
$doc->appendChild( $docFragment );
echo $doc->saveXML();
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux