tags:

views:

21

answers:

2

Hello,

How do I add CDATA to the ViolationInfo in this below XML

<Violations ViolationNo="1" ViolationCD="10G" ConditionCode="" SectionCd="NYCHC 81.35" severity="0" ViolationInfo="Cold holding equipment not properly maintained in that two door reach-in refrigerator in kitchen observed holding potentially hazardous milk and operating at an internal temperature of 48°F.. All potentially hazardous foods were discarded as per violation 2G" Point="5" Occurence="0" ViolationDate="2/17/2010 7:58:00 AM"></Violations>

When I tried to put as shown below I am getting an error saying cannot have < in the value

<![CDATA[Facility conditions conducive to the existence of pest life in that several holes, approximately 2-3 inches in diameter noted in ceiling throughout rear food storage area and throughout basement.]]>
A: 

You cannot put a CDATA section inside a value, nor it is meaningful — values already can only contain text data, you don't need to wrap it inside a CDATA section.

KennyTM
But when I have a degree symbol in the text it is throwing error saying invalid character.
acadia
@acadia: Make the file to use Unicode encoding.
KennyTM
A: 

Drop the CDATA and escape the attribute text or move the violation info to its own tag.

<Violations>
 <ViolationInfo><![CDATA[Facility conditions conducive to the existence of pest life in that several holes, approximately 2-3 inches in diameter noted in ceiling throughout rear food storage area and throughout basement.]]></ViolationInfo>
</Violations>
gum411