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

How to transform & nbsp; in XSLT

I have a following xslt: After transformation I get: &nbsp;Some text which is rendered as: & nbsp;Some text I want to render & nbsp; as…
zosim
  • 2,959
  • 6
  • 31
  • 34
5
votes
2 answers

Reading XML CDATA section with ]] in it

I'm coding a RSS reader in Javascript using XMLHttpRequest. For some RSS Feeds I had no problems but in some cases the xmlDocument.firstChild attribute was always NULL After trying to see the differences between the XML that worked and the ones that…
YasuDevil
  • 470
  • 5
  • 16
5
votes
1 answer

How to handle CDATA in xml parser using ElementTree python?

I just started python and was trying to parse the xml file using ElementTree. But the problem is I have one tag with CDATA which is removed after tree.write. So basically I had this tag
The Red Devil
  • 51
  • 1
  • 5
5
votes
1 answer

How do I get a less than in a javascript for loop in XSL to work?

I am using CDATA to escape the script but in IE8's debugger I still get this message: "Expected ')'" in the for loop conditions. I am assuming it still thinks that the ; in the < generated by CDATA is ending the loop conditions. Original script…
Kyle
  • 63
  • 1
  • 7
5
votes
2 answers

Is starting to use CDATA a breaking change?

For interaction with a customer's application we use XML documents. That is, we send an XML over HTTP and receive a response XML document the same way. The customer specified two XML schemata that describe the format of both the request and reply.…
kicsit
  • 638
  • 5
  • 6
5
votes
3 answers

java adding cdata to xml string

I need to add CDATA to xml string for sign it with certificate. String looks like: someparametres Result must be like: someparametres]]> How can i do this? Pls help P.S. Xml…
NovaCenturion
  • 187
  • 1
  • 3
  • 16
5
votes
3 answers

How to access variable in CDATA from XSLT?

I am using XSLT Transformation and need to put some data in CDATA section and that value is present in a variable. Query: How to access variable in CDATA ? Sample Given Below:
Amit
  • 3,358
  • 9
  • 34
  • 48
5
votes
1 answer

Replace cdata tags in xml

I have an string with possible multiple cdata tags inside: I am using javascript/jquery and I need to remove multiple cdata tags (replace them with…
Toniq
  • 4,492
  • 12
  • 50
  • 109
5
votes
1 answer

Can CDATA sections be preserved by BeautifulSoup?

I'm using BeautifulSoup to read, modify, and write an XML file. I'm having trouble with CDATA sections being stripped out. Here's a simplified example. The culprit XML file:
mwcz
  • 8,949
  • 10
  • 42
  • 63
5
votes
1 answer

Why does CDATA is commented out under script tags ?

I was reading this question and I have a related question : This guy here said that : It is used in script tags to avoid parsing < and &. In HTML, this is not needed, because in HTML, script is already #CDATA. Question #1 If SCRIPT is already…
Royi Namir
  • 144,742
  • 138
  • 468
  • 792
5
votes
1 answer

Count records with a condition in XSLT

I have an xml with this structure:
Afshin Moazami
  • 2,092
  • 5
  • 33
  • 55
5
votes
2 answers

XSLT to copy elements from source into CDATA section

I am transforming a simple SOAP XML message into a more extended SOAP XML message. I got it almost to work, but I can't manage to fix the last 2 issues. My issues are: All elements after the element should be in a CDATA section. I tried to use…
Mark Veenstra
  • 4,691
  • 6
  • 35
  • 66
5
votes
1 answer

Jsoup get contents of javascript that has CDATA tags?

I am using Jsoup to parse a webpage. But some if the info that I want to parse is inside a CDATA tag that prevents the parser from extracting the data inside. How would I go about extracting data from within a CDATA tag? EXAMPLE:
Praxder
  • 2,315
  • 4
  • 32
  • 51
5
votes
1 answer

Problems with MySQL LOAD XML INFILE

I have a XML document in the format of... ]]> 1
Leke
  • 873
  • 3
  • 15
  • 28
5
votes
1 answer

Parsing XML CDATA Blocks

I'm attempting to parse an XML file (using NSXMLParser) from the website librarything.com. This is the first file I have ever parsed, but for the most part it seems fairly straight forward. My problem occurs when trying to parse a CDATA block; the…
Scott Mielcarski
  • 760
  • 6
  • 17