- libxml_use_internal_errors: documentation ( source)
<?php
$html = <<<HTML
<div>
<wiki href="articletitle">Text</wiki>
</div>
HTML;
$appPath = 'http://myapps/page/';
$dom = new DOMDocument;
libxml_use_internal_errors(true);
$dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
foreach ($dom->getElementsByTagName('wiki') as $wiki) {
$a = $dom->createElement('a');
$a->setAttribute('href', $appPath . $wiki->getAttribute('href'));
$a->nodeValue = $wiki->nodeValue;
$wiki->parentNode->replaceChild($a, $wiki);
}
echo $dom->saveHTML();