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.x ml")
'change the xml file
objXMLDocument. Save("C:\test.x ml") 6 11392
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.x ml") 'change the xml file objXMLDocument. Save("C:\test.x ml")
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(fa lse) 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(fa lse) 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!P LEASEtkachenko. com> wrote in message
news:e7******** ******@TK2MSFTN GP10.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(fa lse) 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(fa lse));
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.XmlD ocument
d.LoadXml("<roo t><child/></root>")
Dim tw As New IO.StreamWriter ("C:\test.xm l", False, New
System.Text.UTF 8Encoding(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!P LEASEtkachenko. com> wrote in message news:e7******** ******@TK2MSFTN GP10.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(fa lse) 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 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
class, the output is:
|
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
|
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 Save method, and write this to a file I can then reload this correctly.
However since I have no need to write the data to file I want to save it as a stream then reload it the stream.
However If I do this I have suddenly lost the root element
...
|
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 instruction
document (not data based) - same as using an xml web control.
The resulting html is on the client? but what about the server side of
things? Trying to figure out how to change and save the xmlDocument.
It I put a button OUTSIDE of the...
|
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.
I'm a bit bewildered by the choices available (XmlSerialization, XmlWriter,
Xml on SQL Server) and do not have any experience with them, so I was
wondering what is the best way to do this?
| |
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 attributes of <html>. When I then insert new XmlNodes
into the DOM the HTML tags all end up getting an unnecesarry 'xmlns'
attribute added, elements with the 'r' prefix don't, which is correct. Is
there any way to stop the XmlNode/XmlWriter from...
|
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 normal XmlDoc to
another I don't have any issue, the nodes are copied but then with this
serialized object it doesn't seem to work.
The C# code:
|
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 MyDocument();
doc.Load("input.txt"); // doc is now an XmlDocument
// Query or modify the XmlDocument as usual
doc.Save("output.xml"); // doc saved using XmlDocument.Save();
That is, the input file is not XML, and the Load() method is obviously
|
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 concurrently updating.
However I'm still seeing "System.IO.IOException: The process cannot
access the file "c:\file1.xml" because it is being used by another
process." The following is the test program
public class XmlTest
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |