1

I am currently trying to parse xml file using java but while parsing i am unable to parse the tags present inside the CDATA section of any element tag. The whole data inside the CDATA section is being parsed as text while parsing using DOM or SAX.

please suggest any way without any hard coding.

<Evaluation>
<![CDATA[<evaluation>
<interview ratingtype="0"/>
<item description="Ability to communicate well with others verbally and in writing:" hasrating="True" hascomments="False" /> ............ </item>
 </evaluation> ]]
</Evaluation>
1
  • What u did so far to achieve this ? Share some code to better understand. Commented Nov 20, 2014 at 13:18

2 Answers 2

2

CDATA sections are text nodes. So the parser is correct reading it as a single string. CDATA sections mean that the parser will not do any decoding of entities. You can read more about it in the specification.

If you want to treat the contents of a CDATA section as an XML document or fragment you need to do this manually - in other words: parse it separately.

Sign up to request clarification or add additional context in comments.

Comments

0

CDATA represents text nodes, as mentioned above. It won't make sense to keep tags inside a CDATA section. CDATA should be used to store plain strings.

In this case the , and tags won't get parsed as elements by the parser.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.