1

I have a XML file and I need to extract the info in "<![CDATA[" tag using Castor in spring-mvc. I need to know how to write the mapping.xml file.

Here is the XML:

    <comprobante>
     <![CDATA[<?xml version="1.0" encoding="UTF-8"?>
      <comprobanteRetencion id="comprobante" version="1.0.0">
      ****
      </comprobanteRetencion>
     ]]>
    </comprobante>
Luis Teijon
  • 4,769
  • 7
  • 36
  • 57
  • I removed the tag. Here is the solution: [Solution](http://stackoverflow.com/questions/31306682/org-xml-sax-saxexception-illegal-text-data-found-as-child-of/33043205#33043205) – Luis Teijon Oct 09 '15 at 22:40

2 Answers2

1

Only you can know what the "info" in this XML is. As far as the XML parser and schema are concerned, your XML fragment is precisely equivalent to

<comprobante>
     &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;comprobanteRetencion id="comprobante" version="1.0.0"&gt;
      ****
      &lt;/comprobanteRetencion&gt;

    </comprobante>

That is, the CDATA tag is just a way of saying "don't treat angle brackets in here as markup".

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
  • Then, it means that I can't map or extract the content in CDATA tag? – Luis Teijon Sep 28 '15 at 01:13
  • 1
    I don't know whether Castor provides any workaround, but in general, I would not expect tools to provide mechanisms that treat CDATA as something that has structural semantics, because the consensus in the XML world is that it does not. – Michael Kay Sep 29 '15 at 07:31
0

I removed the tag CDATA. Once I removed that tag, I could treat the xml file normally. Here is the whole solution

Community
  • 1
  • 1
Luis Teijon
  • 4,769
  • 7
  • 36
  • 57