如何将CDATA添加到以下XML
中的ViolationInfo中<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>
当我尝试按下图所示放置时,我收到一条错误消息,说不能有&lt;在值
<![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.]]>
答案 0 :(得分:1)
删除CDATA并转义属性文本或将违规信息移动到自己的标记。
<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>
答案 1 :(得分:-1)
您不能将CDATA部分放在值中,也不能有意义 - 值已经只能包含文本数据,您不需要将它包装在CDATA部分中。