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
7
votes
3 answers

Nested CDATA - correctly

That's problem in XML document: Title Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud…
Eugene Shmorgun
  • 2,083
  • 12
  • 42
  • 67
7
votes
5 answers

How to preserve newlines in CDATA when generating XML?

I want to write some text that contains whitespace characters such as newline and tab into an xml file so I use Element element = xmldoc.createElement("TestElement"); element.appendChild(xmldoc.createCDATASection(somestring)); but when I read this…
clamp
  • 33,000
  • 75
  • 203
  • 299
6
votes
1 answer

cdata in jax-ws / wsimport

I created a soap client with wsimport and i need to send xml data inside of a string field in the message to the webserver. I know that i dont really need to use a cdata in a webservice call but the webservice needs this field to be in cdata…
Oliver Dalley
  • 101
  • 1
  • 4
6
votes
1 answer

How can I retain CDATA tags when storing query results in an Xml variable?

When I generate Xml in Sql Server 2008 R2 using For Explicit (because my consumer wants one of the elements wrapped in CDATA) and store the results in an Xml variable, the data I want wrapped in CDATA tags no longer appears wrapped in CDATA tags. If…
Mavyak
  • 61
  • 1
  • 4
6
votes
7 answers

innerHTML converts CDATA to comments

I'm trying to insert some HTML into a page using javascript, and the HTML I'm inserting contains CDATA blocks. I'm finding, in Firefox and Chrome, that the CDATA is getting converted to a comment. The HTML is not under my control, so it's difficult…
Rich
  • 15,048
  • 2
  • 66
  • 119
6
votes
1 answer

File exported from SVGator fails to compile in React

This is my first time posting a question. Please be cool if I don't know all the etiquette.. I am working with an SVG animation that I built-in SVGator. I am loading it into my react app as a loading page. The SVG file itself displays fine in the…
Jmac-Code
  • 85
  • 1
  • 6
6
votes
1 answer

Markdown within yaml / yaml multi-line escape sequence?

Is it possible to store unescaped markdown documents in yaml? I've tested key:|+ markdown text block that could have any combination of line breaks, >, -, :, ', " etc etc. This does not work. I need something like CDATA or python style…
user331782
  • 101
  • 1
  • 4
6
votes
3 answers

jQuery and XML (with CDATA)

I've seen the post that deal with this issue but I still can't solve my issue: I've got XML with CDATA and when I parse the XML, it includes the CDATA (which I don't want). XML sample:
6
votes
1 answer

Thymeleaf and inline scripts SAXParseException

I got a page which uses thymeleaf template, and I'm getting the following error on page load when using inline scripts: org.xml.sax.SAXParseException; lineNumber: 270; columnNumber: 85; The content of elements must consist of well-formed…
Alexandru Severin
  • 6,021
  • 11
  • 48
  • 71
6
votes
2 answers

PCDATA vs CDATA in XML DTD

In XML DTD's - When defining an element , we use #PCDATA to say that this element can contain any parseable text. When defining an attribute , we use CDATA to say that its value can be any character data. CDATA as is used in XML is something which…
nikel
  • 3,402
  • 11
  • 45
  • 71
6
votes
2 answers

Javascript CDATA section

Recently, I was creating a module to add google remarketing tag to a webstore. I have prepared google_tag_params for different type of pages (product, category, cart etc.) according to the documentation. Everything went well until the client checked…
Zefiryn
  • 2,240
  • 2
  • 20
  • 30
6
votes
1 answer

BizTalk - CDATA in a message assignment shape

I am setting the value of an element inside a Message Assignment shape of an Orchestration. I am using XPATH function to do it. The text needs to be contained inside a CDATA section. This is how I tried to do it: xpath(messageOut,…
gmang
  • 435
  • 1
  • 6
  • 20
6
votes
3 answers

XML Serialization of HTML

Okay this one DID it! Thanks to all of you! public class Result { public String htmlEscaped { set; get; } [XmlIgnore] public String htmlValue { set; get; } [XmlElement("htmlValue")] public…
csharpnoob
  • 505
  • 1
  • 9
  • 24
5
votes
5 answers

Can't run JavaScript in CDATA

I am trying to run following HTML in every browser: Opera, FF, IE, Chrome
Mike Starov
  • 7,000
  • 7
  • 36
  • 37
5
votes
2 answers

Need a CDATA event notifying stax parser for java

I have taken over the maintenance of an application that uses a stax parser to break down an XML file of many records into individual records for further processing. Using this type of parser for this purpose is overkill in my opinion but I didn't…
user1110046
  • 53
  • 1
  • 4