I take HTML in as a string and then I parse it to change all href links to something else. This works however, when the HTML page has some JS script tags i.e. <script>
it gets removed! For example this line:
<script type="text/javascript" src="/js/jquery.js"></script>
Gets Changed to:
[removed][removed]
However, I would like to keep everything in. This is my function:
function parse_html_code($code, $code_id){
libxml_use_internal_errors(true);
$xml = new DOMDocument();
$xml->loadHTML($code);
foreach($xml->getElementsByTagName('a') as $link) {
$link->setAttribute('href', CLK_BASE."clk.php?i=$code_id&j=" . $link->getAttribute('href'));
}
return $xml->saveHTML();
}
I appreciate any help on this.