473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Reading XML Data

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
4 1024
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dariusz | last post by:
Below is part of a code I have for a database. While the database table is created correctly (if it doesn't exist), and data is input correctly into the database when executed, I have a problem...
0
by: Andy | last post by:
Hi, In the code below (not pretty I know but it's an early version :-P) I'm having problems reading the data object back in. If I move the reading code to immediately after the section where it...
1
by: Magnus | last post by:
allrite folks, got some questions here... 1) LAY-OUT OF REPORTS How is it possible to fundamentaly change the lay-out/form of a report in access? I dont really know it that "difficult", but...
6
by: KevinD | last post by:
assumption: I am new to C and old to COBOL I have been reading a lot (self teaching) but something is not sinking in with respect to reading a simple file - one record at a time. Using C, I am...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
10
by: Tyler | last post by:
Hello All: After trying to find an open source alternative to Matlab (or IDL), I am currently getting acquainted with Python and, in particular SciPy, NumPy, and Matplotlib. While I await the...
5
blazedaces
by: blazedaces | last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing...
4
by: Shark | last post by:
Hi, I need a help. My application reads data from COM port, this data is then parsed and displyed on: 1. two plotters 2. text box. I'm using Invoke method to update UI when new data is...
13
by: swetha | last post by:
HI Every1, I have a problem in reading a binary file. Actually i want a C program which reads in the data from a file which is in binary format and i want to update values in it. The file...
6
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.