Timbo292832
Member
Hi Guys
lately i have been working with xml files
i am able to write a xml file and read it but when i write to the xml file it overwrites everything that is not to be overwritten
it overwrites the file completely with a new xml
can someone please tell me how i can edit the xml
as in add elements without loosing my existing ones
here is a example of my code to writing xml
Dim settings As New XmlWriterSettings()
settings.Indent = True
Dim XmlWrt As XmlWriter = XmlWriter.Create("MyXML.xml", settings)
With XmlWrt
' Write the Xml declaration.
.WriteStartDocument()
' Write a comment.
.WriteComment("XML Database.")
' Write the root element.
.WriteStartElement("Data")
' Start our first person.
.WriteStartElement("Person")
' The person nodes.
.WriteStartElement("FirstName")
.WriteString("Alleo")
.WriteEndElement()
.WriteStartElement("LastName")
.WriteString("Indong")
.WriteEndElement()
' The end of this person.
.WriteEndElement()
' Close the XmlTextWriter.
.WriteEndDocument()
.Close()
End With
MessageBox.Show("XML file saved.")
End If
lately i have been working with xml files
i am able to write a xml file and read it but when i write to the xml file it overwrites everything that is not to be overwritten
it overwrites the file completely with a new xml
can someone please tell me how i can edit the xml
as in add elements without loosing my existing ones
here is a example of my code to writing xml
Dim settings As New XmlWriterSettings()
settings.Indent = True
Dim XmlWrt As XmlWriter = XmlWriter.Create("MyXML.xml", settings)
With XmlWrt
' Write the Xml declaration.
.WriteStartDocument()
' Write a comment.
.WriteComment("XML Database.")
' Write the root element.
.WriteStartElement("Data")
' Start our first person.
.WriteStartElement("Person")
' The person nodes.
.WriteStartElement("FirstName")
.WriteString("Alleo")
.WriteEndElement()
.WriteStartElement("LastName")
.WriteString("Indong")
.WriteEndElement()
' The end of this person.
.WriteEndElement()
' Close the XmlTextWriter.
.WriteEndDocument()
.Close()
End With
MessageBox.Show("XML file saved.")
End If