0

i want to use CDATA within CDATA in XML i tried following codes, but both are showing error.

1.

 <extraScript><![CDATA[

        <subScript><![CDATA[this.value]]></subScript>

 ]]></extraScript>

2.

 <extraScript><![CDATA[

        <subScript><![CDATA[this.value]]]]><![CDATA[></subScript>

 ]]></extraScript>

i refereed this post in SO

according to that answer i tried second one but </subScript> is making problem how i can escape these part. some helps??

Community
  • 1
  • 1
chriz
  • 1,339
  • 2
  • 16
  • 32

1 Answers1

4

You can't nest CDATA blocks.

The first ]]> will terminate the first CDATA block and then the next end tag will not be well-formed.

Use character references (&lt; et al) instead.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • check this [post](http://stackoverflow.com/questions/12860754/using-cdata-inside-another-cdata) in SO – chriz Jan 08 '15 at 10:36
  • 1
    @chriz — That is another approach you could take, although it is not "escaping" anything, and still doesn't have nested CDATA blocks. – Quentin Jan 08 '15 at 10:37
  • @chriz — Why do you want a third solution? You have two already. – Quentin Jan 08 '15 at 10:41
  • <![CDATA[ <![CDATA[this.value]]]]><![CDATA[></subScript> ]]> did u mean like this and none of these solutions are working for me :( – chriz Jan 08 '15 at 10:42
  • No. I said **instead**. You should have only a single CDATA block. – Quentin Jan 08 '15 at 10:47