Parsing HTML source to make some replacements

115 views Asked by At

I am trying to parse an HTML source to make some changes on it. Until now I was using Simple HTML Dom Parser but I am facing some memory leaking although using clear() function as in documentation.

So I decided to try PHP DOM and PHPQUERY but both are giving me the exact same problem. Even just loading dom, it is breaking in the exactly same location. It is removing some tags.

php dom

$dom = new DOMDocument;
$dom->loadHTML($html);
$html = $dom->saveHTML();

phpquery

require('phpQuery.php');
$html = phpQuery::newDocumentHTML($html);

source code page before

<input type="radio" id="logo_show0" name="logo_show" value="1" checked="checked" />

...

$(document).ready(function() {
    var tab = $('<li class=" active"><a href="#general" data-toggle="tab">Plugin</a></li>');
    $('#myTabTabs').append(tab);
});

source code page after

<input type="radio" id="logo_show0" name="logo_show" value="1" checked />

...

$(document).ready(function() {
    var tab = $('<li class=" active"><a href="#general" data-toggle="tab">Plugin');
    $('#myTabTabs').append(tab);
});

Has been removed checked and closing tags </a></li>.

What I am doing wrong?

0

There are 0 answers