views:

570

answers:

5

How to encode special characters in xml? e.g: i have a special character mu in my xml, transformation will fail due to this character any info would be helpful

Thanks Preetham

A: 

you can encode your xml in utf-8 and use

<node><![CDATA[ odd characters here ]]></node>
TheBrain
Joachim Sauer
+1  A: 

Any valid UTF-8 character should be fine in XML, and any XML processing tool (including XSLT) should handle them also. If the file is valid XML, then it should work. Can you post an example XML file that is giving you trouble?

skaffman
Should be fine, provided you specify no encoding or specify UTF-8!
Joachim Sauer
A: 

XML text defaults to the UTF-8 encoding. This supports all characters you care to throw at it. Only by deliberately selecting a non-international encoding would it fail to encode correctly.

Christian Hayter
A: 

This is sometimes referred to as "escaping", see here for example.

Neko
+2  A: 

If you are building up your XML via string concatenation then you need to stop doing that and start using a library (e.g. DOM) in your language to create the XML.

The library will handle encoding correctly.

WW
I wish I could upvote you twice!
John Saunders