I need to read an xml from string(parse the xml based on the element name).The Xml (string) is retrieved from database and is stored in a string and is passed in the loadxml(stringname)..but its showing error in the particular location as token should seek for end element..try to find me the solution as i couldn't able to get the solution for this particular scenario in net and i also had posted the code along with this mail....And if possible send me the solution to my personal mail id too(
[email protected])
CODE:
If Page.IsPostBack = True Then
Dim strxml As String
Dim cn As New SqlConnection("Server=EPROINDIA55;uid=sa;pwd=sensi ple;database=NorthWind")
Dim str As String
str = "Select xmlval from detail where id='" + DropDownList1.SelectedItem.Text + "'"
Dim cmd As New SqlCommand(str, cn)
cn.Open()
Dim rd As SqlDataReader
rd = cmd.ExecuteReader()
While rd.Read()
With rd
strxml = .Item("xmlval")
End With
End While
Response.Write(strxml)
Dim a As String
a = TextBox1.Text
Dim reader As XmlNodeReader = Nothing
Try
Dim doc As New XmlDocument
//ERROR IS POINTED IN THE FOLLOWING LINE
doc.LoadXml(strxml)
reader = New XmlNodeReader(doc)
reader.MoveToContent()
While reader.Read()
Select Case reader.NodeType
Case XmlNodeType.Element
If reader.Name = TextBox4.Text Then
'Response.Write((reader.Name & "='" & reader.ReadInnerXml & "'"))
TextBox1.Text = reader.ReadInnerXml
TextBox2.Text = reader.ReadInnerXml
TextBox3.Text = reader.ReadInnerXml
End If
End Select
End While
Finally
If Not (reader Is Nothing) Then
reader.Close()
End If
End Try
End If