cdata

R

Richard Barnet

Regarding including escaped dynamic content (such as user-generated text
from a <textarea>), when should I use <![CDATA[ ... ]]> as opposed to
&lt;![CDATA[ ... ]]&gt; ?

When I use the first one, I get a residual "]]>" that displays on the page.
I've noticed this problem on others' pages, too. I've also seen some sites
that use the latter, but this doesn't seem to make sense, and doesn't seem
to be explained anywhere that I can find.

-- Richard
 
D

Dan Brussee

Regarding including escaped dynamic content (such as user-generated text
from a <textarea>), when should I use <![CDATA[ ... ]]> as opposed to
&lt;![CDATA[ ... ]]&gt; ?

When I use the first one, I get a residual "]]>" that displays on the page.
I've noticed this problem on others' pages, too. I've also seen some sites
that use the latter, but this doesn't seem to make sense, and doesn't seem
to be explained anywhere that I can find.

-- Richard

<CDATA> sections are used in XML to contain free entered text that the
programmer has no control over. It's only purpose is to make sure that
the contents will work in the XML structure since someone could type in
<ABC>123</AABBCC> which would fail any XML parser.

Making this <![CDATA[<ABC>123</AABBCC>]]> causes the parser to accept
it. It is still up to the programmer to handle the text inside in a
reasonable way.
 
R

Richard Barnet

Dan Brussee said:
<CDATA> sections are used in XML to contain free entered text that the
programmer has no control over. It's only purpose is to make sure that
the contents will work in the XML structure since someone could type in
<ABC>123</AABBCC> which would fail any XML parser.

Making this <![CDATA[<ABC>123</AABBCC>]]> causes the parser to accept
it. It is still up to the programmer to handle the text inside in a
reasonable way.

This is precisely what I need it for (for content that is outside my
control). Why is it, however, that the browser (IE 6.0 SP1 in strict mode)
displays the "]]>" after the content?

-- Richard
 
D

Dan Brussee

Dan Brussee said:
<CDATA> sections are used in XML to contain free entered text that the
programmer has no control over. It's only purpose is to make sure that
the contents will work in the XML structure since someone could type in
<ABC>123</AABBCC> which would fail any XML parser.

Making this <![CDATA[<ABC>123</AABBCC>]]> causes the parser to accept
it. It is still up to the programmer to handle the text inside in a
reasonable way.

This is precisely what I need it for (for content that is outside my
control). Why is it, however, that the browser (IE 6.0 SP1 in strict mode)
displays the "]]>" after the content?

Can you give an example? I would think you would be sending this through
an XSL transformation and not just trying to show it's value inside a
text area :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top