473,602 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlDocument and utf-8

A question: all the XML files I've seen use this declaration:

<?xml version="1.0" encoding="UTF-8"?>

BUT files created using XmlDocument have:

<?xml version="1.0" encoding="utf-8"?>

(you see? lowercase UTF)

I've even tried "manually correcting" the utf to UTF with notepad and then
opening with XmlDocument and saving.

Are they equivalent? Am I doing something wrong?

--- bye
Jun 16 '07 #1
4 5919
Yes. No.
"MaxMax" <no**@none.comw rote in message
news:P_******** ************@tw ister1.libero.i t...
>A question: all the XML files I've seen use this declaration:

<?xml version="1.0" encoding="UTF-8"?>

BUT files created using XmlDocument have:

<?xml version="1.0" encoding="utf-8"?>

(you see? lowercase UTF)

I've even tried "manually correcting" the utf to UTF with notepad and then
opening with XmlDocument and saving.

Are they equivalent? Am I doing something wrong?

--- bye
Jun 16 '07 #2
Hi Max,

Yes, both "UTF-8" and "utf-8" is ok for the charset in XML declaration
section. And the .net framework XmlDocument just always convert the charset
value to lower case for consistency purpose.

In addition, the <?xml ....?declaratio n's charset value is only a
suggestion value for some XML processing programs, the actual
charset/encoding format of a XML document/file still rely on how you write
out the document(throug h file I/O api). In other words, the actual
charset/encoding of a XML file may be different from the charset
declaration in the <?xml ....?section

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 18 '07 #3
Yes, both "UTF-8" and "utf-8" is ok for the charset in XML declaration
section. And the .net framework XmlDocument just always convert the
charset
value to lower case for consistency purpose.

In addition, the <?xml ....?declaratio n's charset value is only a
suggestion value for some XML processing programs, the actual
charset/encoding format of a XML document/file still rely on how you write
out the document(throug h file I/O api). In other words, the actual
charset/encoding of a XML file may be different from the charset
declaration in the <?xml ....?section
Just checked the XML standard (fourth edition) (just to be sure... 99% of
the internet can't be wrong... or can it?)
"XML processors SHOULD match character encoding names in a case-insensitive
way "

The "official" name of UTF-* is UTF-* uppercase, but the parser should parse
it in a case insensitive way.

--- bye
Jun 18 '07 #4
On Jun 18, 3:29 am, stch...@online. microsoft.com (Steven Cheng[MSFT])
wrote:
Yes, both "UTF-8" and "utf-8" is ok for the charset in XML declaration
section. And the .net framework XmlDocument just always convert the charset
value to lower case for consistency purpose.

In addition, the <?xml ....?declaratio n's charset value is only a
suggestion value for some XML processing programs, the actual
charset/encoding format of a XML document/file still rely on how you write
out the document(throug h file I/O api). In other words, the actual
charset/encoding of a XML file may be different from the charset
declaration in the <?xml ....?section
It's not really a "suggestion " - it's the encoding which should be
used to parse the rest of the document. If you claim (in the
declaration) to use UTF-8 and actually use some other encoding, XML
parsers are almost certainly going to fail to understand the data in
the way you expect.

Jon

Jun 18 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2447
by: Francesc Guim Bernat | last post by:
Dear Colleagues, i'm developing a C++ .NET based application that works with System.Xml library. My problem appears when i try to save a document througt XmlDocument->Save method, because it seems to add some strange characters at the beginning of the saved XML document. For instance, if first i print the document throught System::Console
2
14842
by: xmlguy | last post by:
This is part of the application that reads XML from file (that has UTF-8) into an XmlTextReader XmlTextReader myXmlReader = new XmlTextReader(args); It then instantiates an object/class instance Render where this constructor gets called with "that" XmlReader. public Render(XmlReader cleanxmldoc)
1
6807
by: Shawn | last post by:
Hi. I'm using a FileStream (instead of just the path to the xml file) to load an XmlDocument. I'm doing this because I need to be able to prevent other processes to update the file I'm working on. The problem is that I'm getting multiple processing instructions and multiple root elements in my xml file when I use a FileStream. Here is an example: test_1.xml contains: <?xml version="1.0" encoding="utf-8"?> <root>
7
4167
by: Mark | last post by:
Hi... A colleague just referred this question to me. He's getting an xml file from another party, which he's trying to process into another dom using an XmlTextReader and XmlDocument.ReadNode(). The problem is that it's breaking and he doesn't understand why. I didn't exactly either, which is why I'm posting a question here. First, his program just creates a new dom using new document like this: XmlDocument xml = new XmlDocument();
2
5409
by: Chua Wen Ching | last post by:
Hi there, I have 2 questions to ask. 1) I have this code... XmlDocument doc = new XmlDocument(); doc.Load(myXmlPath); int maxValue = 0;
4
4641
by: MattBell | last post by:
I've tried to search for an answer to this without much success, and I think it's probably a common thing to do: I have a web service I want to accept an XmlDocument as an argument which conforms to a specific XSD that is defined. Right now when I declare XmlDocument as my argument, it puts the old xml:any type in. How do I change that to reflect the XSD that I'm looking for? Thanks for any Help!
10
13945
by: lamxing | last post by:
Dear all, I've spent a long time to try to get the xmldocument.load method to handle UTF-8 characters, but no luck. Every time it loads a document contains european characters (such as the one below, output from google map API), it always said invalid character at position 229, which I believe is the "ß" character. Can anyone point me to the right direction of how to load such documents using the xmldocument.load() method, or...
0
1707
by: =?Utf-8?B?R2VvcmdlIFNodWk=?= | last post by:
I have some code like this: public static string SerializObject(object obj) { string xmlString = string.Empty; using (MemoryStream msReq = new MemoryStream()) { using (XmlTextWriter wsReq = new XmlTextWriter(msReq, UTF8)) { XmlSerializer xsR = new XmlSerializer(obj.GetType());
2
9267
by: yxq | last post by:
I want to add some elements to a XML file using XmlDocument, how to do? thank you very much. The original XML file like: //////////////////////////////////////////////////////// <?xml version="1.0" encoding="utf-8" ?> <AAA> <BBB> <CCC> <resource name="111">Content1</resource> <resource name="222">Content2</resource>
0
8404
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8268
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5440
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3900
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2418
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1254
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.