Hello everyone!
I'm newbie around here, but i heard that this is a right place for me.
I'm writing a storeyard program with multiple database (XML,MDF,XLS...) in
VB.NET.
I have a problem with adding a new node (child) in XML file.
Here is code:
Code:
Private Sub save_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save_btn.Click
Dim writer As New XmlTextWriter("C:\Documents and Settings\Vladimir\My Documents\Visual Studio 2008\Projects\skladiste_app\sklad.xml", System.Text.Encoding.UTF8)
writer.WriteStartDocument(True)
writer.Formatting = Formatting.Indented
writer.Indentation = 2
writer.WriteStartElement("article")
create_node(sybling_count.ToString, name_article_XML.Text, type_article_xml.Text, Cypher_article_xml.Text, num_xml.Text, writer)
writer.WriteEndElement()
writer.WriteEndDocument()
writer.Close()
End Sub
Private Sub create_node(ByVal pID As String, ByVal pName As String, ByVal pType As String, ByVal pCyph As String, ByVal pNum As String, ByVal writer As XmlTextWriter)
writer.WriteStartElement("artikal")
writer.WriteStartElement("ID_article")
writer.WriteString(pID)
writer.WriteEndElement()
writer.WriteStartElement("Name")
writer.WriteString(pName)
writer.WriteEndElement()
writer.WriteStartElement("Type")
writer.WriteString(pType)
writer.WriteEndElement()
writer.WriteStartElement("Cyphre")
writer.WriteString(pSyph)
writer.WriteEndElement()
writer.WriteStartElement("Number")
writer.WriteString(pNum)
writer.WriteEndElement()
writer.WriteEndElement()
End Sub
The issue is that on every data writing it overwrites the old data.
I know there must be an easy way for adding new child to the end of the document. I found some tags for xml but this suppose to be an automatically generated file, so it doesn't work for me.
Those variable names are changed, originally they were in Croatian language, so if you find some irregularity with program flow, ignore it.
Any help is appreciated!