...

View Full Version : Escaping special characters in XML



jessjenn
01-05-2004, 06:29 AM
I want to have special characters in elements so rather than using htmlentities(), I'm using <![CDATA[ ]]>. An example would be the following:



<DATA>
<REPORT_DATE><![CDATA[ 11-Nov-2003 ]car & ><<><>< < ]]></REPORT_DATE>
<IP_RECORD>
<ADDRESS>67.31.42.63</ADDRESS>
<HOSTNAME>dialup-67.31.42.63.Dial1.NewYork1.Level3.net</HOSTNAME>
<OWNER>Broomfield CO 80021 United States</OWNER>
</IP_RECORD>

<IP_RECORD>
<ADDRESS>152.163.253.33</ADDRESS>
<OWNER>VA 20166 United States</OWNER>
</IP_RECORD>
</DATA>


Now, characters such as & > < ' " work fine. The problem is when I use the ] [ characters inside <![CDATA[ ]]>. Is it because I have to escape these bracket characters? In this case "11-Nov-2003 ]" doesn't get displayed, just what follows. It's because of the "]".

Any thoughts? Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum