I just tried this one : https://github.com/paquettg/php-html-parser and it seems great.
What HTML parser are you using ?
Hello,
I need to replace some text content inside some tags in an HTML document, I have tried with DOMDocument PHP native library, but it's not convenient for me because it transforms my HTML code by adding the HTML and BODY tags.
And I need to maintain exactly the same tags organization with just replacing the text inside them.
So I'm looking for another HTML parser.
Have you already used these ones ?
https://github.com/paquettg/php-html-parser
https://packagist.org/packages/ammadeuss/laravel-html-dom-parser
Perhaps you know another one ?
I specify that the HTML string is typed inside a form and is not in a file.
Thanks for your help.
Vincent
I have tried with DOMDocument PHP native library, but it's not convenient for me because it transforms my HTML code by adding the HTML and BODY tags.
If that is your only problem you can easily remove them.
With laravel's helper this basic thing should work:
$yourHtml = '<html><head></head><body>Hello!</body></html>';
$cleanedHtml = \Str::between($yourHtml, '<body>', '</body>');
Please or to participate in this conversation.