473,395 Members | 1,797 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,395 software developers and data experts.

Formatting XMLDcoument

Hi

When using the XmlDocument.OuterXml property after adding some nodes and
attributes, it returns the entire document correctly, but it's actually all
on one line. How can I format the document that it becomes readable by
humans, with CRLFs and Tabs?

Thanks for any hints. Urs
Nov 21 '05 #1
3 1141


Urs Vogel wrote:

When using the XmlDocument.OuterXml property after adding some nodes and
attributes, it returns the entire document correctly, but it's actually all
on one line. How can I format the document that it becomes readable by
humans, with CRLFs and Tabs?


You can save using an XmlTextWriter for which you set Formatting to
Indented:
xmlTextWriter.Formatting = Formatting.Indented
xmlDocument.Save(xmlTextWriter)

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 21 '05 #2
Thanks.

"Martin Honnen" <ma*******@yahoo.de> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.phx.gbl...


Urs Vogel wrote:

When using the XmlDocument.OuterXml property after adding some nodes and
attributes, it returns the entire document correctly, but it's actually
all on one line. How can I format the document that it becomes readable
by humans, with CRLFs and Tabs?


You can save using an XmlTextWriter for which you set Formatting to
Indented:
xmlTextWriter.Formatting = Formatting.Indented
xmlDocument.Save(xmlTextWriter)

--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 21 '05 #3
Hi Urs

How about this - this will give you a String representation of your XML
document, but with formatting.

Dim d As New Xml.XmlDocument
d.LoadXml("<root><child>Text</child></root>")
Dim sw As New IO.StringWriter
Dim xw As New Xml.XmlTextWriter(sw)
xw.Formatting = Xml.Formatting.Indented
d.Save(xw)
xw.Close()
MessageBox.Show(sw.ToString())
sw.Close()

HTH

Nigel Armstrong

"Urs Vogel" wrote:
Hi

When using the XmlDocument.OuterXml property after adding some nodes and
attributes, it returns the entire document correctly, but it's actually all
on one line. How can I format the document that it becomes readable by
humans, with CRLFs and Tabs?

Thanks for any hints. Urs

Nov 21 '05 #4

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

Similar topics

3
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be...
2
by: Colleyville Alan | last post by:
I am using Access and have embedded the ActiveX control Formula One that came with Office 2000. (ver 3.04). I have created and formatted a spreadsheet and now I want to copy the info with...
4
by: DBQueen | last post by:
I have a subform which is in Continuous Forms view. I have added a button to the bottom of the page to move to the next record using the button wizard (result: DoCmd.GoToRecord , , acNext). I...
4
by: hope | last post by:
Hi, How can I format a string field using Data Formatting Expression property in datagrid? For example: format last name from BROWN to Brown. Thanks
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
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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,...

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.