[xml] Re: HTML Parser: Choking on quoted HTML tags in javascript?




Thank you Morten and Emmanuel for your hints regarding the HTML tag
interpretation in quoted Javascript strings.

I am sure the CDATA syntax is wrong so check up on that.

I will check on that.

I don't know if this is relevant for your problem, but generally it
is recommended to encapsulate such inclusion with the comment tag:

Yes, I compeletely agree with both of your resonses. However, the
application that produces this HTML is a commercial Web app that I cannot
change. I try to get along other "errors" by using the libXML parser and
dealing with it.

Unfortunately the original page renders correctly in browsers but gets
incompatible after being processed by the libxml HTML parser.

Yes. That is because browsers are not XML parsers but HTML parsers and they 
often guess the missing tags and can deal with unclosed tags.

If you wrap your script in 

<script type="text/javascript">
// <![CDATA[
Your script here
//]]>
</script>

the bad xml in the <script> tag will be ignored by XML parsers.

(Now the CDATA syntax should be correct. Now-a-days you do not need to wrap 
your script in <!-- --> ) 

I am sure that will help you, but you couldn't do that? You don't have access 
to the source of the HTML generating script?

I that case I am not sure I understand your problem/question.

Regards,
        Morten




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]