mirror of
https://github.com/Aviortheking/DeltaCMS.git
synced 2025-07-28 20:59:50 +00:00
WIP
This commit is contained in:
31
test.php
Normal file
31
test.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
ini_set('display_errors', 'On');
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$test = "<html><body><p>pouet</p></body></html>";
|
||||
$doc->loadHTML($test);
|
||||
|
||||
appendHTML($doc->getElementsByTagName("body")->item(0), "<img src=\"./\">");
|
||||
|
||||
echo $doc->saveHTML();
|
||||
|
||||
|
||||
function appendHTML(DOMNode $parent, $source) {
|
||||
$tmpDoc = new DOMDocument();
|
||||
$html = "<html><body>";
|
||||
$html .= $source;
|
||||
$html .= "</body></html>";
|
||||
$tmpDoc->loadHTML('<?xml encoding="UTF-8">'.$html);
|
||||
|
||||
foreach ($tmpDoc->childNodes as $item)
|
||||
if ($item->nodeType == XML_PI_NODE)
|
||||
$tmpDoc->removeChild($item);
|
||||
$tmpDoc->encoding = 'UTF-8';
|
||||
|
||||
foreach ($tmpDoc->getElementsByTagName('body')->item(0)->childNodes as $node) {
|
||||
$importedNode = $parent->ownerDocument->importNode($node, true);
|
||||
$parent->appendChild($importedNode);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user