المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Xml Problem



C# Programming
08-11-2009, 12:27 AM
Hello, I have problem reaading XML file using XmlReader. Here is a snipset

StringReader sr = new StringReader(SettingFile);
XmlReaderSettings xrs = new XmlReaderSettings();
xrs.IgnoreWhitespace = true;
xrs.IgnoreComments = true;

XmlReader reader = XmlReader.Create(sr, xrs);

while (reader.Read()) // XmlExpection Here: Data at the root level is invalid. Line 1, position 1.
{

}

reader.Close();
sr.Close();

That expection is so funny, because the xml is properly used. or shoud i say even it was created by XmlWriter. Here is what it looks like:


"1.0" encoding="utf-8"?>









this is how i saved that xml.
XmlWriterSettings xws = new XmlWriterSettings();
xws.Encoding = Encoding.UTF8;
xws.Indent = true;
XmlWriter xw = XmlWriter.Create(SettingFile, xws);


This line was shown by Total Commander without encoding
?»?<span class="code-keyword">