473,382 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Saving to XML file with XmlDocument


Hi,

When using the following code:
doc.PreserveWhitespace = true;
doc.Save(fileName);

where doc is a variable of type "XmlDocument", 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 1580
Mike wrote:

Hi,

When using the following code:

doc.PreserveWhitespace = true;
doc.Save(fileName);

where doc is a variable of type "XmlDocument", 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.Indented

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**************@TK2MSFTNGP10.phx.gbl...
Mike wrote:

Hi,

When using the following code:

doc.PreserveWhitespace = true;
doc.Save(fileName);

where doc is a variable of type "XmlDocument", 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.Indented

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
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...
3
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...
0
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 !=...
1
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...
2
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...
1
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...
1
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...
1
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...
2
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,...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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 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.