#43686 [Opn->Bgs]: It could be possible to import a string into DomDocument
| From: | rrichards@php.net | Date: | Thu, 27 Dec 2007 12:40:29 +0000 |
| Subject: | #43686 [Opn->Bgs]: It could be possible to import a string into DomDocument | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-120884@lists.php.net to get a copy of this message | ||
ID: 43686
Updated by: rrichards@php.net
Reported By: programatorfreez at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: Gentoo GNU/Linux
PHP Version: 5.2.5
New Comment:
Maybe you should read the docs before stating something is broken:
http://www.php.net/manual/en/function.dom-domdocumentfragment-appendxml.php
Previous Comments:
------------------------------------------------------------------------
[2007-12-27 02:50:09] programatorfreez at gmail dot com
Description:
------------
You're missing a very handful feature and it's pretty annoying to make
a workaround which cannot perform exactly what I need until PHP is
fixed.
Reproduce code:
---------------
This is my crappy workaround for the missing Dom->importString(),
however the support in DOM should be made.
/**
* Import a string like something<br /><strong>strong</strong> into
the DomDocument
*
* @param string string
* @param DomElement parent
* @return DomElement reference to imported node
*/
public function importString($string, $parent) {
if ($parent === NULL) {
throw new Exception('Parent cannot be NULL.');
}
$tmp = new DomDocument('1.0', 'utf-8');
// The div is unwanted here, but loadXml doesn't work without it
$tmp->loadXml('<div>' . $string . '</div>');
return $this->domImportNode($tmp->firstChild);
}
Actual result:
--------------
PHP DOM doesn't provide any similar functionaly, although it's needed.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43686&edit=1