Re: Problem with $dom->saveHTML();
| From: | Kirsten Osa | Date: | Fri, 25 Nov 2011 07:46:14 +0000 |
| Subject: | Re: Problem with $dom->saveHTML(); | ||
| References: | 1 2 3 | Groups: | php.qa |
| Request: | Send a blank email to php-qa+get-65998@lists.php.net to get a copy of this message | ||
Hi,
I did check the html with tidy and it has a few warnings. Unfortunately I have no control over the html that I load into the domDocument as this is just content of a web page saved to our database. However there are no problems with matching tags in the saved content in this case so it seems strange that $dom->saveHTML(); rewrites the script section putting the end script in the wrong place.
<script type="text/javascript">
//cto listing tag
document.write('<div id="cto_se_7714219_ac" style="display:none">');
document.write('<div class="ctoWidgetServer">http://lasenzauk.widget.criteo.com/pjl/</script></div>');
document.write('<div class="ctoDataType">sendEvent</div>');
document.write('<div class="ctoParams">wi=7714219&pt1=3&i1=030013744&i2=030013745</div>');
document.write('</div>');
Do you know if there is a work around that I could use?
Regards
Kirsten
On 24/11/2011 11:44, Johannes Schlüter wrote:
On Wed, 2011-11-23 at 08:13 -0800, Christopher Jones wrote:On 11/23/11 4:08 AM, Kirsten Osa wrote:This is no PHP issue. libxml2 has no understanding of the<script> tag but it sees other tags inside the<script> tag, so it is confused and tries its best to find a structure. The JavaScript code should be inside a HTML comment oder XML CDATA block. If there is a bug/feature request that's for libxml2, but I doubt they implement this. Tidy has more understanding of HTML. johannesHi, I am running php 5.3.5 and have got a problem with $dom->saveHTML(); It moves the</script> tag from end of script block to middle of it. See below: I am using $dom = new domDocument; @$dom->loadHTML($sContent); Where $sContent is the Full source of the web page.Can you test with a more recent version of PHP? If you have a standalone testcase, can you log a bug at https://bugs.php.net/report.php ?Thanks, Chris -- Email: christopher.jones@oracle.com Tel: +1 650 506 8630 Blog: http://blogs.oracle.com/opal/----- No virus found in this message. Checked by AVG - www.avg.com Version: 2012.0.1873 / Virus Database: 2101/4637 - Release Date: 11/24/11