How to use Encoding in XML
In this article I have described that how we can use encoding in XML application with the help of example.
XML Encoding
If your XML Document contain non ASCII character and file saved double-byte Unicode with single byte Unicode specified than you can get Encoding Error problem. You can also get this Error if your XML was saved with single-byte ASCII with double-byte Encoding specified. XML Document can contain non ASCII character like French ê è é to avoid Error specify the XML Encoding. If you save XML file in Notepad then file save single-byte ASCII by default if you select Save as then file will be save double-byte Unicode.
Example
If you save your XML file as below than not will be generate any error
<?xml version="1.0"?>
<note>
<from>Hello</from>
<to>Travel</to>
<message>Norwe: æøå. Frenchs: êèé</message>
</note> |
If you save your XML file as below than error will be generated.
<?xml version="1.0"? encoding="windows-1252"? >
<note>
<from>Hello</from>
<to>Travel</to>
<message>Norwe: æøå. Frenchs: êèé</message>
</note> |
Further Readings
You may also want to read these related articles :here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here