473,804 Members | 3,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Saving to XML file with XmlDocument


Hi,

When using the following code:
doc.PreserveWhi tespace = true;
doc.Save(fileNa me);

where doc is a variable of type "XmlDocumen t", the XML file is saved with the correct information by the indentation is not kept. Any idea why?

Also, the first character of the XML file is "". Any idea why?

Thanks so much.
Mike

Nov 16 '05 #1
2 1604
Mike wrote:

Hi,

When using the following code:

doc.PreserveWhi tespace = true;
doc.Save(fileNa me);

where doc is a variable of type "XmlDocumen t", the XML file is saved
with the correct information by the indentation is not kept. Any idea why?
If you want to save an XmlDocument with indentation, use an instance of
XmlTextWriter with the Formatting property set to Formatting.Inde nted

Also, the first character of the XML file is "". Any idea why?

The characters you're refering to are the Unicode markers for the text file.
Thanks so much.
Mike

--

Ed Courtenay
[MCP, MCSD]
http://www.edcourtenay.co.uk
Nov 16 '05 #2

Great, thanks!
"Ed Courtenay" <re************ *************** **@edcourtenay. co.uk> wrote in message news:#H******** ******@TK2MSFTN GP10.phx.gbl...
Mike wrote:

Hi,

When using the following code:

doc.PreserveWhi tespace = true;
doc.Save(fileNa me);

where doc is a variable of type "XmlDocumen t", the XML file is saved
with the correct information by the indentation is not kept. Any idea why?
If you want to save an XmlDocument with indentation, use an instance of
XmlTextWriter with the Formatting property set to Formatting.Inde nted

Also, the first character of the XML file is "". Any idea why?

The characters you're refering to are the Unicode markers for the text file.
Thanks so much.
Mike



--

Ed Courtenay
[MCP, MCSD]
http://www.edcourtenay.co.uk
Nov 16 '05 #3

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

Similar topics

2
1491
by: Gerald Maher | last post by:
Hi Reading in XML file, changing elements and saving back to the file, how can i do that, I want to be able to read an XML file and read out Elements. for example <name>Tom</tom> When I read from a file i want to save the XML document in memory of the computer and when i am finished flush it back to the file, that
3
3209
by: smita | last post by:
Hi, I am trying to write to an Xml document. My xml file is present is in the current working directory but whenever i try to make changes to the file and save the change in the XML file (which i specify as a parameter to doc.Save() method) it searches for the file in F:/WINNT/System32 folder... Even if I specify the path explicitly to "F:\Inetpub\wwwroot\WebApplication4\UserPass.xml" it gives an error.
0
1247
by: Bill | last post by:
I have a strong typed dataset which I load using the following code. try { XmlTextReader xmlTR = new XmlTextReader("XIF-v1.0.xsd"); dsMyDataSet.ReadXmlSchema(xmlTR); if (p_FileName != string.Empty) { _FileName = p_FileName; dsMyDataSet.LoadData();
1
1591
by: TT (Tom Tempelaere) | last post by:
Hi there, I load an Xml document into an XmlDocument object. I look up some nodes using SelectNodes/SelectSingleNode, and I modify the InnerText property. After this I call the XmlDocument.Save method on the XmlDocument object, BUT, the changes are NOT written! The resulting Xml document is identical to the original. Basically what I do is this:
2
2380
by: Throne Software | last post by:
I am working on a ASP .Net page with a C# back end that displays, and give the option to save, an XmlDocument object. While displaying the XML in a literal was easy, I can't figure out how to allow the user to save the XmlDocument as a file without creating an XML file on the server. It is important that the XML file is not created server side. Any insight to my problem would be most appreciated.
1
1588
by: Blue Man | last post by:
Anybody has idea how to save value in web.config file during runtime? ConfigurationSettings.AppSettings.Add("test","test value"); won't work, it will cause and error : the file is read only during rumtime.
1
1788
by: woostersoz | last post by:
Hi I have a toolbar written in .NET C++. I use the XMLDocument Load method to open a file from a URL (which points to a remote server). So far, so good.. I then edit this file's nodes in memory and then I want to save it back to the same location (URL) from which I opened it. When I try to do this using the XMLDocument Save method, I get an error message "URI formats are not supported".
1
1804
by: Patrick.O.Ige | last post by:
I have this small snippet below and i want to save some data back to the xml file. So i looked for a node and checked if the node value is the same as a textbox value and if yes i pass in the new value entered from a textbox back t the xml datasource. I'm populating values of the textboxes from an xml dtrasource But it doesn't see to work am i missing something Thanks in advance
2
5857
by: Al Pilon | last post by:
Any help would be appreciated for the following problem. I've already spent a day at this, and enough is enough. I'm writing a ORM program. and in the process of running it against a database, I'm creating dozens of classes. I want to insert these classes into the .csproj file automatically. I can do it just fine manually, and I can do it also programatically up to the point that I save the XmlDocument object. At that point, for some...
0
10589
Oralloy
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...
0
10340
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
10327
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
10085
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
9161
agi2029
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...
1
7625
isladogs
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...
0
5527
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...
1
4302
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
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.