R
René Paschold
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).Value
txtLinks.Text = _
xml.DocumentElement.ChildNodes(1).ChildNodes(0).Value
AxDHTMLEdit1.DOM.body.innerHTML = _
xml.DocumentElement.ChildNodes(2).ChildNodes(0).Value
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é
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).Value
txtLinks.Text = _
xml.DocumentElement.ChildNodes(1).ChildNodes(0).Value
AxDHTMLEdit1.DOM.body.innerHTML = _
xml.DocumentElement.ChildNodes(2).ChildNodes(0).Value
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é