Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / January 2008

Tip: Looking for answers? Try searching our database.

Problems with special characters in XML

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Norbert Pürringer - 24 Jan 2008 09:37 GMT
Hello,

I would like to read out an XML file using the XMLDocument object
writing the simple code:

               XmlDocument xmlDoc = new XmlDocument();
               xmlDoc.Load(file);

My XML file contains special characters (German ones) using the
encoding "ISO-8859-1". This file is of course saved in that encoding
format.

My problem is, that the XMLDocument seems to ignore the West European
encoding defined in the XML file by showing me the German character
"ü" as "?" (question mark). What must be done to read out German
characters by the XMLdocument correctly?

Regards,
Norbert
Andy Fish - 24 Jan 2008 11:32 GMT
are you sure it's not just the way you are outputting the strings that is
causing the perceived problem?

as long as the encoding declaration in the xml directive matches the actual
encoding being used, there should be no problem loading it into an
XMLDocument

Andy

Hello,

I would like to read out an XML file using the XMLDocument object
writing the simple code:

               XmlDocument xmlDoc = new XmlDocument();
               xmlDoc.Load(file);

My XML file contains special characters (German ones) using the
encoding "ISO-8859-1". This file is of course saved in that encoding
format.

My problem is, that the XMLDocument seems to ignore the West European
encoding defined in the XML file by showing me the German character
"ü" as "?" (question mark). What must be done to read out German
characters by the XMLdocument correctly?

Regards,
Norbert
Norbert Pürringer - 24 Jan 2008 13:33 GMT
The problem seems to be the webservice. In the context of the
webserver, the XML document is able to read out the encoding
correctly. But if a client gets the XML document through a web service
call, the XML document does not contain any correct special
characters. What must be done to solve my problem?
Martin Honnen - 24 Jan 2008 14:35 GMT
> The problem seems to be the webservice. In the context of the
> webserver, the XML document is able to read out the encoding
> correctly. But if a client gets the XML document through a web service
> call, the XML document does not contain any correct special
> characters. What must be done to solve my problem?

I have never understood why you need a web service if you want to return
an XML document. Consider to simply use a HTTP handler on the server
which returns the XML document as needed.

As for the web service problem, there is
microsoft.public.dotnet.framework.aspnet.webservices.

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

Andy Fish - 24 Jan 2008 16:44 GMT
i would guess that your problem is to do with the HTTP encoding. Probably
your web service is sending a HTTP header specifying UTF-8 encoding (which
obviously doesn't match up with the XML document)

you might need to use a network monitor like ethereal to figure out what is
actually going over the wire

FWIW with my current application, we use utf-8 wherever possible (certainly
for all XML files and HTTP traffic) because it minimises these sort of
issues

Andy

> The problem seems to be the webservice. In the context of the
> webserver, the XML document is able to read out the encoding
> correctly. But if a client gets the XML document through a web service
> call, the XML document does not contain any correct special
> characters. What must be done to solve my problem?
Martin Honnen - 24 Jan 2008 13:31 GMT
> I would like to read out an XML file using the XMLDocument object
> writing the simple code:
[quoted text clipped - 10 lines]
> "ü" as "?" (question mark). What must be done to read out German
> characters by the XMLdocument correctly?

If the characters are properly encoded then they should be properly
read. Here
<URL:http://home.arcor.de/martin.honnen/xml/test2008012401.xml> is an
example with German umlauts, I have no problem reading and outputting
that document:
      XmlDocument doc = new XmlDocument();

doc.Load(@"http://home.arcor.de/martin.honnen/xml/test2008012401.xml");
      doc.Save(Console.Out);

Can you post a URL to your document? I think it is not properly encoded.
What happens when you load your document in a browser like IE or
Firefox? Are the umlauts correctly rendered?

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.