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

XML CDATA Encoding

I am trying to build an XML document in C# with CDATA to hold the text inside an element. For example.. However, when I get the InnerXml property of the document, the CDATA has been reformatted so the…
Nick
8
votes
5 answers

java: remove cdata tag from xml

xpath is nice for parsing xml files, but its not working for data inside the cdata tag: more text and tags

... ]]> My solution: Get the content of the xml first and remove "". After that I would run…
SandyBr
  • 11,459
  • 10
  • 29
  • 27
8
votes
4 answers

Use CDATA to store raw binary streams?

Instead of the overhead with saving binary as Base64, I was wondering if you could directly store double-byte binary streams into XML files, using CDATA, or commenting it out, or something?
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
8
votes
0 answers

Not introducing CDATA with just one value

My Wrapper class is this: @XmlRootElement(name = "GETA") public class EfGetAResponseWrapperXmlObject { private String something; @XmlElement(name = "result") public String getSomething() { return something; } public…
Goldbones
  • 1,407
  • 3
  • 21
  • 55
8
votes
5 answers

XML Serialization - XmlCDataSection as Serialization.XmlText

I am having problems serializing a cdata section using c# I need to serialize XmlCDataSection object property as the innertext of the element. The result I am looking for is this: hello…
Adam Jenkin
  • 4,142
  • 6
  • 25
  • 31
7
votes
6 answers

What is the regex expression for CDATA

Hi I have an example CDATA here and The CDATA regex i have is not able to recognize this "])*"]]>" this does not work…
Freddy Chua
  • 113
  • 1
  • 1
  • 11
7
votes
1 answer

Extracting content from

I am having a string like: "consectetur siptum. adipiscing elit. Phasellus pulvinar hendrerit malesuada. Mauris eget ante nulla. Suspendisse tempus lorem id.]]>" using jquery…
Jojo
  • 71
  • 1
  • 2
7
votes
2 answers

Is CDATA really necessary?

I use inline Javascript quite a bit, usually in WordPress themes that I make. I had not heard of wrapping inline Javascript in // up until a few months ago, and I have been doing this stuff at a fair level of competency for a few…
Daniel
  • 199
  • 1
  • 2
  • 7
7
votes
2 answers

.Net XmlSerializer: deserialize CDATA being inner text

I have a problem with CDATA deserialization using standard .Net XmlSerializer. Update: I get XML from external system and I can't influence it's format so I can't make CData be enclosed in a separate Element of Attribute. Serialization gives…
Konstantin Spirin
  • 20,609
  • 15
  • 72
  • 90
7
votes
5 answers

How to get CDATA from xml node using xsl ?

I am trying to get the CDATA content of an XML node using XSL. The node currently looks like this: I need the This is sample text piece. Does anyone have any idea about…
VJOY
  • 3,752
  • 12
  • 57
  • 90
7
votes
1 answer

How to create SOAP request with CDATA

I am new to SOAP,I want to create SOAP request,as given below
LMK
  • 2,882
  • 5
  • 28
  • 52
7
votes
2 answers

Removing CDATA tag from XmlNode

I have an XmlNode which represents the following xml for example: XmlNode xml.innerText = I want to change this node so that it'll contain the…
Niv
  • 2,294
  • 5
  • 29
  • 41
7
votes
3 answers

Transform XML with XSLT and preserve CDATA (in Ruby)

I am trying to convert a document with content like the following into another document, leaving the CDATA exactly as it was in the first document, but I haven't figured out how to preserve the CDATA with XSLT. Initial XML:
Lance
  • 75,200
  • 93
  • 289
  • 503
7
votes
3 answers

SQL Server XML output with CDATA

Is there a way to have an SQL Server XML return use CDATA? I have XML being returned by SQL Server like this: Texas A & M When I am required to have…
Steve -Cutter- Blades
  • 5,057
  • 2
  • 26
  • 40
7
votes
1 answer

PHP, SimpleXML, decoding entities in CDATA

I'm experiencing the following behavior: $xml_string1 = ""; $xml_string2 = " Someone's Name "; $person = new SimpleXMLElement($xml_string1); print…
Cassie
  • 292
  • 1
  • 3
  • 9