How do you encode special characters in the XML?

How do you encode special characters in the XML?

Postby Kishan » Thu Feb 07, 2013 5:38 am

How do you encode special characters in the XML?
Kishan
 
Posts: 191
Joined: Tue Jan 29, 2013 4:21 am

Re: How do you encode special characters in the XML?

Postby Kishan » Mon Feb 25, 2013 4:50 am

Following characters are special characters in XML.
<, >, Quote, & etc..

XML Entities: &lt; &gt; &amp; &quot;

Replacing above special characters with xml entities is called as encoding.
You can acheive encode in two ways:
1) Best way to encoding is write a text inside PCDATA so parsers treat them accordingly.
2) Write java method will replace special chars with entity chars.

Example:
Code: Select all
<math><![CDATA[a > b ]]></math>
Kishan
 
Posts: 191
Joined: Tue Jan 29, 2013 4:21 am


Return to XML

Who is online

Users browsing this forum: No registered users and 1 guest

cron