473,324 Members | 2,313 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,324 software developers and data experts.

Problems with read XML

Hello,

i write a xml file with following code:

Dim xWriter As New XmlTextWriter(SaveFileContent.FileName, _
Encoding.UTF8)

With xWriter

.Formatting = Formatting.Indented
.Indentation = 4
.WriteStartDocument()
.WriteComment("RootNote")

.WriteStartElement("article")

.WriteStartElement("headline")
.WriteString(txtHead.Text)
.WriteEndElement()

.WriteString("links")
.WriteString(txtLinks.Text)
.WriteEndElement()

.WriteStartElement("content")
.WriteString(AxDHTMLEdit1.DOM.body.innerHTML)
.WriteEndElement()

.WriteEndElement()

.WriteEndDocument()
.Close()

End With

It works great. Now the Problem. If i want to read this created XML
File and one of the nodes are emtpy than i cant read the rest. Here is
the code to read:

Dim xml As New XmlDocument
xml.Load(OpenFileContent.FileName)

txtHead.Text = _
xml.DocumentElement.ChildNodes(0).ChildNodes(0).Va lue

txtLinks.Text = _
xml.DocumentElement.ChildNodes(1).ChildNodes(0).Va lue

AxDHTMLEdit1.DOM.body.innerHTML = _
xml.DocumentElement.ChildNodes(2).ChildNodes(0).Va lue

What is the best way to write and read simple XML Files
with only three nodes to save program content or save
program settings (like ini file).

Greetings
René

Nov 20 '05 #1
1 1100
Cor
Hi René

I don't think there is a best way.

When you have only 3 elements in a XML file with only 3 values, do it the
way that is the most simple for you. When I see your code (I never used it
that way but what I understand from it) I just would write the empty
elements with empty values.

When you want to do it without it, I think that in your example the best way
could be searching (reading) for the text element, the next value item in
the read is then your value.

But it there are so much posibilities,
Take what you fits the best with your 3 element XML file.

I hope this helps a little bit.

Cor
Nov 20 '05 #2

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

Similar topics

6
by: Sara Khalatbari | last post by:
Dear friends In a code, I'm opening a file to read. Like : lines = open(filename).readlines() & I'm never closing it. I'm not writing in that file, I just read it. Will it cause any problems...
0
by: yukon | last post by:
Hi there the next is my platform IIS5 windows 2000 asp vbscript My working area has the next virtual directoy: testAc (corrective ambient) testAe (evolutionary ambient)
2
by: jfixsen | last post by:
Hello! Oracle 9.2.0.4 SunOS pchi-db01 5.8 Generic_108528-19 sun4u sparc SUNW,Ultra-EnterpriseSystem = SunOS Node = pchi-db01 Release = 5.8 KernelID = Generic_108528-19 Machine = sun4u...
13
by: nick4soup | last post by:
General advice wanted: Some web sites (including two large companies in Australia) get themselves awfully confused if the user presses the BACK button in their browser (and possibly the forward...
0
by: Robert Björn | last post by:
I'm trying to process a MemoryStream of XML data, which at any point in time may have incomplete fragments (because data arrives from a socket). If I process data until XmlTextReader.Read()...
6
by: George McLean | last post by:
Hello, I am trying to isolate some performance issues. The database is DB2 v8.1 running on a Win2000 server with 4 processors and 1gb of RAM. The application is a GIS application that uses...
0
by: Sherif ElMetainy | last post by:
Hello I am making an application that generates source code. I am facing some problems. 1- How can I generate code that uses the c# 'params' keyword to specify multiple arguments? I tried 2...
4
by: JC - home | last post by:
Hello.. I've been having some problems for a little while with this which I was sure I would beat...hmmm. Anyway, I have a form with two rich textboxes. One at the top which is to display a...
2
by: goodnamesalltaken | last post by:
Hello fellow python users, I've been working on a basic implementation of a privilege separated web server, and I've goto the point of running a basic cgi script. Basically when the execCGI...
2
by: Mike | last post by:
Hi, I am new to C and having problems with the following program. Basically I am trying to read some files, loading data structures into memory for latter searching. I am trying to use structres...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.