Using The code in vb.net im having a product error when i enter infromatoion.
The Error is
Invailidoperation...............
Token StartElement in state Epilog would result in an invalid XML document.
heres the code im working on
Imports System.Xml
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim writer As New XmlTextWriter("C:\Documents and Settings\Justin\Desktop\Pictures\XMLFile\product.xml", System.Text.Encoding.UTF8)
writer.WriteStartDocument(True)
writer.Formatting = Formatting.Indented
writer.Indentation = 2
writer.WriteStartElement("Table")
createNode(1, TextBox1.Text, TextBox5.Text, TextBox9.Text, writer)
createNode(2, TextBox2.Text, TextBox6.Text, TextBox10.Text, writer)
createNode(3, TextBox3.Text, TextBox7.Text, TextBox11.Text, writer)
createNode(4, TextBox4.Text, TextBox8.Text, TextBox12.Text, writer)
writer.WriteEndElement()
writer.WriteEndDocument()
writer.Close()
End Sub
Private Sub createNode(ByVal pID As String, ByVal pName As String, ByVal pPrice As String, ByVal pAmount As String, ByVal writer As XmlTextWriter)
writer.WriteStartElement("Product")
writer.WriteStartElement("Product_id")
writer.WriteString(pID)
writer.WriteEndElement()
writer.WriteStartElement("Product_name")
writer.WriteString(pName)
writer.WriteEndElement()
writer.WriteStartElement("Product_price")
writer.WriteString(pPrice)
writer.WriteEndElement()
writer.WriteEndElement()
writer.WriteStartElement("PAmount")
writer.WriteString(pAmount)
writer.WriteEndElement()
writer.WriteEndElement()
End Sub
End Class
all of this is in runtime when the error happenes
The Error is
Invailidoperation...............
Token StartElement in state Epilog would result in an invalid XML document.
heres the code im working on
Imports System.Xml
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim writer As New XmlTextWriter("C:\Documents and Settings\Justin\Desktop\Pictures\XMLFile\product.xml", System.Text.Encoding.UTF8)
writer.WriteStartDocument(True)
writer.Formatting = Formatting.Indented
writer.Indentation = 2
writer.WriteStartElement("Table")
createNode(1, TextBox1.Text, TextBox5.Text, TextBox9.Text, writer)
createNode(2, TextBox2.Text, TextBox6.Text, TextBox10.Text, writer)
createNode(3, TextBox3.Text, TextBox7.Text, TextBox11.Text, writer)
createNode(4, TextBox4.Text, TextBox8.Text, TextBox12.Text, writer)
writer.WriteEndElement()
writer.WriteEndDocument()
writer.Close()
End Sub
Private Sub createNode(ByVal pID As String, ByVal pName As String, ByVal pPrice As String, ByVal pAmount As String, ByVal writer As XmlTextWriter)
writer.WriteStartElement("Product")
writer.WriteStartElement("Product_id")
writer.WriteString(pID)
writer.WriteEndElement()
writer.WriteStartElement("Product_name")
writer.WriteString(pName)
writer.WriteEndElement()
writer.WriteStartElement("Product_price")
writer.WriteString(pPrice)
writer.WriteEndElement()
writer.WriteEndElement()
writer.WriteStartElement("PAmount")
writer.WriteString(pAmount)
writer.WriteEndElement()
writer.WriteEndElement()
End Sub
End Class
all of this is in runtime when the error happenes