Re: Problem with $dom->saveHTML();
| From: | Johannes Schlüter | Date: | Thu, 24 Nov 2011 11:44:21 +0000 |
| Subject: | Re: Problem with $dom->saveHTML(); | ||
| References: | 1 2 | Groups: | php.qa |
| Request: | Send a blank email to php-qa+get-65989@lists.php.net to get a copy of this message | ||
On Wed, 2011-11-23 at 08:13 -0800, Christopher Jones wrote:
>
> On 11/23/11 4:08 AM, Kirsten Osa wrote:
> > Hi,
> >
> > 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 ?
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.
johannes
> Thanks,
>
> Chris
>
> --
> Email: christopher.jones@oracle.com
> Tel: +1 650 506 8630
> Blog: http://blogs.oracle.com/opal/
>