469,343 Members | 5,546 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

Parse a xml file


I'm trying to parse in c# DotNet a xml file (file.FullName) that as no encoding type, and one of the tag is compose with 'ç' or 'é' or 'ã'
but in the c# DotNet declaration of the var new_s those characters not appear !

See example:
xml file.FullName:
<?xml version="1.0" ?>
<![CDATA[serviço , or, Coronárias

XmlSerializer s = new XmlSerializer(typeof(XML_CLASS));
StreamReader stream = new StreamReader(file.FullName);
confFile = (XML_CLASS)s.Deserialize(stream);

string new_s = confFile.Report.ToString();
In string new_s the characters 'ç' or 'é' or ' í ' or 'ã' not appear!
Can someone help me?

Thanks to all.
Mar 7 '07 #1
2 1503
839 Expert 512MB
Welcome to TSDN...

Try to set the stream this way (for encoding "ISO-8859-1"):
Expand|Select|Wrap|Line Numbers
  1. StreamReader stream = new StreamReader(file.FullName, System.Text.Encoding.GetEncoding(28591));
I could not test with XML_CLASS class, but it displays correctly with:
Expand|Select|Wrap|Line Numbers
  1. Console.WriteLine(stream.ReadToEnd());
Mar 8 '07 #2
839 Expert 512MB
Did you succeed to solve the problem ?
If yes, please let me know, in order to close the thread.
Mar 21 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

22 posts views Thread by Ram Laxman | last post: by
3 posts views Thread by slylos | last post: by
5 posts views Thread by AdrianH | last post: by
1 post views Thread by AdrianH | last post: by
6 posts views Thread by =?Utf-8?B?RGF2aWRN?= | last post: by
5 posts views Thread by goldtech | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.