PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
Reading XML Data
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
Reading XML Data
![]() |
Reading XML Data |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi,
Code: Dim xmlstring As String = "http://localhost/log.xml" Dim xmlreads As XmlTextReader = New XmlTextReader(xmlstring) Dim id As Integer = 0 Try While xmlreads.Read() Select Case xmlreads.NodeType Case XmlNodeType.Element If InStr(xmlreads.Name, "id") > 0 Then Response.Write(" " + xmlreads.Name + "='" + xmlreads.Value + "'") End If End Select End While 'Response.Write(id.ToString) Catch es As Exception If Not InStr(es.Message, "404") = 0 Then Response.Write("File Not Found!!!!" & InStr(es.Message, "404")) Else Response.Write(InStr(es.Message, "404") & es.Message) End If End Try XMLFILE: <?xml version="1.0" encoding="utf-8" ?> <LOG xmlns="log.xsd"> <id>1</logid> <logdatetime>2002-05-30T09:00:00</logdatetime> <eventtitle>New</eventtitle> <eventdesc>adsadsadsad </eventdesc> <eventby>arangan</eventby> <id>1</logid> <logdatetime>2002-05-30T09:00:00</logdatetime> <eventtitle>New</eventtitle> <eventdesc>adsadsadsad </eventdesc> <eventby>arangan</eventby> </LOG> ERROR: id='' id='' ???? why am i not getting the values ???? Pls Help me Thanks Arvind |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Hi Arvind,
I haven't examined it deeply but a quick glance showed me: The following element invalidates the Xml. <id>1</logid> You need <id>1</id> You have two sets of <id>1</id> <logdatetime>2002-05-30T09:00:00</logdatetime> <eventtitle>New</eventtitle> <eventdesc>adsadsadsad </eventdesc> <eventby>arangan</eventby> I think you might want these to enclosed within a further element: <logevent> <id>1</id> <logdatetime>2002-05-30T09:00:00</logdatetime> <eventtitle>New</eventtitle> <eventdesc>adsadsadsad </eventdesc> <eventby>arangan</eventby> </logevent> Regards, Fergus |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Thanks Fergus,
Sorry, but that problem is corrected, even after that its the same problem. Regards aRvind. "Fergus Cooney" <filter-1@tesco.net> wrote in message news:eBzjvJtjDHA.2436@TK2MSFTNGP09.phx.gbl... > Hi Arvind, > > I haven't examined it deeply but a quick glance showed me: > > The following element invalidates the Xml. > <id>1</logid> > > You need > <id>1</id> > > You have two sets of > <id>1</id> > <logdatetime>2002-05-30T09:00:00</logdatetime> > <eventtitle>New</eventtitle> > <eventdesc>adsadsadsad </eventdesc> > <eventby>arangan</eventby> > > I think you might want these to enclosed within a further element: > <logevent> > <id>1</id> > <logdatetime>2002-05-30T09:00:00</logdatetime> > <eventtitle>New</eventtitle> > <eventdesc>adsadsadsad </eventdesc> > <eventby>arangan</eventby> > > </logevent> > > Regards, > Fergus > > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Hi Arvind
Beside the two errors Fergus did mention already, I changed your code a little bit, you see the two changed line without the >t beneath, I hope that gives the result you want? Cor > Dim xmlstring As String = "http://localhost/log.xml" > Dim xmlreads As XmlTextReader = New XmlTextReader(xmlstring) > Dim id As Integer = 0 > Try > While xmlreads.Read() > Select Case xmlreads.NodeType > Case XmlNodeType.Element > If InStr(xmlreads.Name, "id") > 0 Then xmlreads.Read() Response.Write(" " & "Id='" & xmlreads.Value & "'") > End If > End Select |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Hi Cor,
Thanks a lot i got it. So this means that the identity tag and value tag are at two different level and we need to moveto the next to reterive the value. Thanks Hope this kind of errors are marked. ARvind "Cor" <non@non.com> wrote in message news:3f8679ad$0$28432$48b97d01@reader21.wxs.nl... > Hi Arvind > Beside the two errors Fergus did mention already, I changed your code a > little bit, you see the two changed line without the >t beneath, > I hope that gives the result you want? > Cor > > Dim xmlstring As String = "http://localhost/log.xml" > > Dim xmlreads As XmlTextReader = New XmlTextReader(xmlstring) > > Dim id As Integer = 0 > > Try > > While xmlreads.Read() > > Select Case xmlreads.NodeType > > Case XmlNodeType.Element > > If InStr(xmlreads.Name, "id") > 0 Then > > xmlreads.Read() > Response.Write(" " & "Id='" & xmlreads.Value > & "'") > > > End If > > End Select > > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

