How do I get the following code to not put the Unicode BOM in the file. If
the attribute ecoding=UTF-8 exists, it will put the BOM in the file.
objXMLDocument = New XmlDocument
objXMLDocument.Load("C:\test.xml")
'change the xml file
objXMLDocument.Save("C:\test.xml") 6 11335
Hi Scot
If you are persisting as UTF-8, then of course you will have the byte order
mark. Could you explain what the problem is with it?
One thing you could do is use an encoding like ISO-8859-1 if you don't want
the BOM.
Nigel Armstrong
"Scot" wrote: How do I get the following code to not put the Unicode BOM in the file. If the attribute ecoding=UTF-8 exists, it will put the BOM in the file.
objXMLDocument = New XmlDocument
objXMLDocument.Load("C:\test.xml") 'change the xml file objXMLDocument.Save("C:\test.xml")
Nigel Armstrong wrote: If you are persisting as UTF-8, then of course you will have the byte order mark. Could you explain what the problem is with it?
One thing you could do is use an encoding like ISO-8859-1 if you don't want the BOM.
Btw, in UTF-8 BOM is actually optional. One can supress BOM's output
using new UTF8Encoding(false) constructor.
--
Oleg Tkachenko [XML MVP] http://blog.tkachenko.com
Oleg
Thanks for the info. Very useful.
Nigel Armstrong
"Oleg Tkachenko [MVP]" wrote: Nigel Armstrong wrote:
If you are persisting as UTF-8, then of course you will have the byte order mark. Could you explain what the problem is with it?
One thing you could do is use an encoding like ISO-8859-1 if you don't want the BOM.
Btw, in UTF-8 BOM is actually optional. One can supress BOM's output using new UTF8Encoding(false) constructor.
-- Oleg Tkachenko [XML MVP] http://blog.tkachenko.com
The destination for my XML file is a company that uses Java and they are
having troubles with the BOM.
Forgive my ignorance, but could you explain how to use that object with the
code I provided. I don't really understand how to use that object with the
xmldocument.
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:e7**************@TK2MSFTNGP10.phx.gbl... Nigel Armstrong wrote:
If you are persisting as UTF-8, then of course you will have the byte
order mark. Could you explain what the problem is with it?
One thing you could do is use an encoding like ISO-8859-1 if you don't
want the BOM.
Btw, in UTF-8 BOM is actually optional. One can supress BOM's output using new UTF8Encoding(false) constructor.
-- Oleg Tkachenko [XML MVP] http://blog.tkachenko.com
Scot wrote: The destination for my XML file is a company that uses Java and they are having troubles with the BOM.
Forgive my ignorance, but could you explain how to use that object with the code I provided. I don't really understand how to use that object with the xmldocument.
Something like
XmlTextWriter w =
new XmlTextWriter("C:\test.xml", new UTF8Encoding(false));
objXMLDocument.Save(w);
w.Close();
--
Oleg Tkachenko [XML MVP] http://blog.tkachenko.com
Hi Scot
This sample illustrates the point that Oleg was making:
HTH
Nigel Armstrong
Dim d As New System.Xml.XmlDocument
d.LoadXml("<root><child/></root>")
Dim tw As New IO.StreamWriter("C:\test.xml", False, New
System.Text.UTF8Encoding(False))
d.Save(tw)
tw.Close()
"Scot" wrote: The destination for my XML file is a company that uses Java and they are having troubles with the BOM.
Forgive my ignorance, but could you explain how to use that object with the code I provided. I don't really understand how to use that object with the xmldocument.
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message news:e7**************@TK2MSFTNGP10.phx.gbl... Nigel Armstrong wrote:
If you are persisting as UTF-8, then of course you will have the byte order mark. Could you explain what the problem is with it?
One thing you could do is use an encoding like ISO-8859-1 if you don't want the BOM.
Btw, in UTF-8 BOM is actually optional. One can supress BOM's output using new UTF8Encoding(false) constructor.
-- Oleg Tkachenko [XML MVP] http://blog.tkachenko.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
by: Tom Pearson |
last post by:
I have created an XmlDocument and can see that this is correctly formed and has a root element
If I Save the doc to a file and reload it all works o
If I dump the doc to a stream, again using the...
|
by: KathyB |
last post by:
If someone could just explain this to me...I just don't get it!
I have an aspx page where I retrieve several session variables and use
xmlDocument to transform xml file with xsl file into an...
|
by: Jack Fox |
last post by:
I'm still new to Xml, but finding it very useful.
Conceptually what I want to do is compress an XmlDocument, save it to SQL
Server as image data, read it back and restore it to an XmlDocument.
...
|
by: David Grogan |
last post by:
Hi, 2 questions....
1. I'm parsing an XHTML document that contains both the default namespace
(xmlns="http://www.w3.org/1999/xhtml") and a custom one (xmlns:r="...") -
both of these being...
|
by: Pierre |
last post by:
Hi,
I'm trying to select specific nodes from a XmlDocument filled with a
serialized object and to insert these nodes into another XmlDocument.
The object is well serialized (see below). From a...
|
by: Gustaf |
last post by:
I have a class that contains a certain kind of XML document. The input
file is *not* an XmlDocument, but when loaded, I want it to work like
the XmlDocument class, like:
MyDocument doc = new...
|
by: liuhengyi |
last post by:
Hi,
I have a test program that creates 5 threads and each thread uses
XmlDocument.Save(filename) to save a Xml dom to a file. I have put the
lock statement around the Save to prevent from...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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...
| |