470,620 Members | 1,441 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Using XmlTextReader to read unicode characters

I have a unicode XML file that I am trying to read using the .NET
XmlTextReader in C#. How do I read the unicode file? If I try to
using the XmlTextReader.Read() method, it throws an exception.

The exception reads:
The 'Ä' character, hexadecimal value 0x80, cannot begin with a name.
Line 1, position 2.

Any suggestions? I read on Microsoft's website about writing surrogate
pairs, but I can't find any documentation that confirms the
XmlTextReader can handle surrogate pairs.

Nov 17 '05 #1
1 3876


Jordan wrote:
I have a unicode XML file that I am trying to read using the .NET
XmlTextReader in C#. How do I read the unicode file? If I try to
using the XmlTextReader.Read() method, it throws an exception.
What Unicode encoding does that XML file have (e.g. UTF-8 or UTF-16)?
How do you know it is Unicode?
Is there an XML declaration (e.g. <?xml version="1.0"
encoding="UTF-8"?>) at the beginning? Is there a BOM (byte order mark)?
How do you create the XmlTextReader, simply with
new XmlTextReader("file.xml")
?
The exception reads:
The 'Ä' character, hexadecimal value 0x80, cannot begin with a name.
Line 1, position 2.


Maybe the XML is not properly encoded? How do the first lines of the XML
file look?
What happens when you load the file with the IE browser? Does that give
a parse error too?

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Michael | last post: by
2 posts views Thread by Q | last post: by
3 posts views Thread by Brad Wood | last post: by
1 post views Thread by Mudcat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.