0

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?

2
  • did you tell the doctype to DOMDocument ? or try the others options of "loadHTML" php.net/manual/en/domdocument.loadhtml.php. for JavaScript, try to protect the code whith CDATA for example Commented Jun 11, 2015 at 12:01
  • @mmm Thanks. Unfortunately I have no control over the code to parse, even so it is possible to protect scripts with CDATA as you suggested? How can I do it? Commented Jun 11, 2015 at 23:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.