Timmi
Timmi

Reputation: 825

How can we save special symbols in xml

I am saving "Children’s Music & videos" to xml

so i used the following code to convert the special symbols

        string str = "Children’s Music & videos";
        string temp = HttpUtility.HtmlEncode(str);

but the xml is not readable after saving the encoded value. How can i save this special symbols to xml

Thanks,

Upvotes: 2

Views: 2441

Answers (3)

rogeriopvl
rogeriopvl

Reputation: 54154

You should use the the tag <![CDATA[ ]]> to wrap around text with special characters.

Here's more on CDATA.

Upvotes: 0

warren
warren

Reputation: 33473

I believe you need to save the special character as its numerical &<nnnn>; representation.

Please see Wikipedia for more - http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1504172

If you have the right text in the string to start with, using the normal XML APIs should encode everything properly for you.

My guess is that you have bad text in your strings. See my Debugging Unicode Problems article for suggestions.

Upvotes: 2

Related Questions