Groups | Blog | Home
all groups > dotnet xml > september 2004 >

dotnet xml : Saving XmlDocument with Danish Encoding????


M O J O
9/17/2004 3:06:10 PM
Hi,

I'm trying to update a vbproj xml file programatically, but when I try to
open the updated vbproj file in Vs.Net, all entries ("Files") with danish
chars are wrong.

How do I force the XmlDocument.Save to encode to Danish chars
('ISO-8859-1')?

Thanks in advance.

M O J O

v-kevy NO[at]SPAM online.microsoft.com
9/18/2004 3:18:08 AM
Hi MOJO,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to save the xml document to a
file which is encoded with ISO-8859-1 format. If there is any
misunderstanding, please feel free to let me know.

We can see that XmlDocument.Save has an overload public virtual void
Save(TextWriter);. We can create a StreamWriter and set the encoding of
that StreamWriter to achieve this. Here is an example:

xmlDocument.Save(new StreamWriter(filename, false,
System.Text.Encoding.GetEncoding("ISO-8859-1")));

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
AddThis Social Bookmark Button