Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...