Questions tagged [cdata]

CDATA (literally, character data) is data that will not be parsed as markup in XML and SGML documents.

While technically "all text that is not markup constitutes the character data" of an XML document (and a similar definition applies for SGML), the term CDATA is typically used in the context of CDATA sections.

A CDATA section begins with the string <![CDATA[ and ends with the string ]]>. The data inside a CDATA section is not parsed as markup within an XML or SGML document - which can be useful when representing XML or SGML within an XML or SGML document:

<![CDATA[
  <html>
    <head>
      <title>This is not markup ...</title>
    </head>
    <body>
      <p>... and neither is this.</p>
    </body>
  </html>
]]>

A CDATA section may contain any sequence of characters except for the string ]]> (which would terminate the section). One way to work around this limitation is to terminate the CDATA section after the string ]] and then begin a new one immediately, starting with the final >. For instance,

<![CDATA[How to represent ']]]]><![CDATA[>' inside a CDATA section.]]>

is equivalent to

How to represent ']]>' inside a CDATA section.
1111 questions
20
votes
1 answer

How to read CDATA in XML file with PowerShell?

I am having a difficult time reading an XML file with Cdata inside. in $xmlsource Test randomHTMLhere
]]>
powershell [xml]$xml =…
puttputt
  • 1,259
  • 2
  • 14
  • 25
20
votes
7 answers

Strip whitespace and newlines from XML in Java

Using Java, I would like to take a document in the following format: and convert it to: I tried the following, but it isn't giving me…
Jannis Ioannou
  • 1,692
  • 1
  • 14
  • 17
17
votes
5 answers

What is the meaning of CDATA

Gurus, I am self taught. There's a lot of what you enlightened ones call basic I know nothing about. Reading this jQuery Tutorial, I noticed this tag (for lack of better word): "CDATA" as shown here (third line from the top):
Chris
  • 1,667
  • 6
  • 34
  • 52
17
votes
4 answers

Should I use "]]>" or "//]]>" for closing a CDATA section into xHTML

I want to inline scripts or CSSs into XHTML without escaping special characters. I can do that using a CDATA marked section. According to http://www.w3.org/TR/xhtml1/#h-4.8 the CDATA section can be defined as: Looks like it…
bomanden
  • 314
  • 1
  • 2
  • 16
14
votes
2 answers

Variable in CDATA in Scala

Is there a way to put a variable to be expanded in a cdata section in scala val reason =
maxfridbe
  • 5,872
  • 10
  • 58
  • 80
13
votes
4 answers

What exactly is CDATA and what does it do?

I sometimes notice a CSS or JS code surrounded with tags. I couldn't find any explanation to this. What does CDATA do? Why is it used by some people and what is it needed for?
rhino
  • 13,543
  • 9
  • 37
  • 39
13
votes
4 answers

parse html inside cdata using jquery or javascript

I'm getting a website feed that looks like this some title this tag is ignored
who took the cookie in the cookie jar!? ]]> I need the entire content of…
Bahamut
  • 1,929
  • 8
  • 29
  • 51
13
votes
3 answers

Error! using CDATA in strings.xml resource Android

I have a string resource in my Android project, and I am using a CDATA section to embed my string in XML:

Acknowledgements

Senator Paul Wellstone's book, the …

letroot
  • 276
  • 1
  • 4
  • 13
12
votes
3 answers

Rendering HTML Tags from within CDATA tag in XSL

I have a CDATA tag within my XML code which contains some hyperlinks.
Grizzly Peak Software
  • 1,428
  • 4
  • 15
  • 20
12
votes
2 answers

How to use CDATA in SQL XML

Could someone please help me with an XML output template please. I have been requested by a client to create an xml output file. This file will then feed in to Client's CRM. So that's why, it has to be an exact match of Client's requested template.…
user3482527
  • 227
  • 1
  • 2
  • 22
1
2
3
74 75