By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,681 Members | 1,338 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,681 IT Pros & Developers. It's quick & easy.

Reading XML Data

P: 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
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: 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
Nov 20 '05 #2

P: n/a
Thanks Fergus,
Sorry, but that problem is corrected, even after that its the same problem.

Regards
aRvind.
"Fergus Cooney" <fi******@tesco.net> wrote in message
news:eB**************@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

Nov 20 '05 #3

P: n/a
Cor
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


Nov 20 '05 #4

P: 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" <no*@non.com> wrote in message
news:3f***********************@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


Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.