From: programatorfreez at gmail dot com
Operating system: Gentoo GNU/Linux
PHP version: 5.2.5
PHP Bug Type: Feature/Change Request
Bug description: It could be possible to import a string into DomDocument
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 bug report at http://bugs.php.net/?id=43686&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=43686&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=43686&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=43686&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=43686&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=43686&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=43686&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=43686&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=43686&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=43686&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=43686&r=support
Expected behavior: http://bugs.php.net/fix.php?id=43686&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=43686&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=43686&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=43686&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43686&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=43686&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=43686&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=43686&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=43686&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=43686&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=43686&r=mysqlcfg