473,396 Members | 1,608 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,396 software developers and data experts.

Reading from XML

Hi All,

Ok, this must be a simple one, I'm trying to read a certain elements
contents from an XML file. Heres what I've come up with so far, which
seems
to get stuick in a loop (ASPNET.EXE hogs the CPU until I kill it!)

Public Function GetPageName(ByVal XMLFileName As String) As String
Dim XmlReader As New
XmlTextReader(Session("DataLocation").ToString
& XMLFileName)

XmlReader.Read()
While Not XmlReader.EOF
If XmlReader.Name = "Title" Then
Return XmlReader.ReadString()
End If
End While

'Return XmlReader.ReadElementString("Title")
XmlReader.Close()
End Function
Note that session("datalocation") is a full path.

Thanks,
Simon.
--
I am using the free version of SPAMfighter for private users.
It has removed 2168 spam emails to date.
Paying users do not have this message in their emails.
Try www.SPAMfighter.com for free now!
Nov 19 '05 #1
3 1177
XmlReader.Read()
While Not XmlReader.EOF
If XmlReader.Name = "Title" Then
Return XmlReader.ReadString()
End If
End While

This is endless loop. It is normal ASP.NET to crash what are u trying to do?
try to XPathNavigator or something like it.
--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"Simon Harris" <to***********@makes-you-fat.com> wrote in message
news:Od**************@TK2MSFTNGP09.phx.gbl...
Hi All,

Ok, this must be a simple one, I'm trying to read a certain elements
contents from an XML file. Heres what I've come up with so far, which
seems
to get stuick in a loop (ASPNET.EXE hogs the CPU until I kill it!)

Public Function GetPageName(ByVal XMLFileName As String) As String
Dim XmlReader As New
XmlTextReader(Session("DataLocation").ToString
& XMLFileName)

XmlReader.Read()
While Not XmlReader.EOF
If XmlReader.Name = "Title" Then
Return XmlReader.ReadString()
End If
End While

'Return XmlReader.ReadElementString("Title")
XmlReader.Close()
End Function
Note that session("datalocation") is a full path.

Thanks,
Simon.
--
I am using the free version of SPAMfighter for private users.
It has removed 2168 spam emails to date.
Paying users do not have this message in their emails.
Try www.SPAMfighter.com for free now!

Nov 19 '05 #2
Thanks - I used dataset.ReadXml to turn the XML into a dataset.

"Yunus Emre ALPÖZEN [MCAD.NET]" <ye***@msakademik.net> wrote in message
news:uL**************@TK2MSFTNGP10.phx.gbl...
XmlReader.Read()
While Not XmlReader.EOF
If XmlReader.Name = "Title" Then
Return XmlReader.ReadString()
End If
End While

This is endless loop. It is normal ASP.NET to crash what are u trying to
do? try to XPathNavigator or something like it.
--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"Simon Harris" <to***********@makes-you-fat.com> wrote in message
news:Od**************@TK2MSFTNGP09.phx.gbl...
Hi All,

Ok, this must be a simple one, I'm trying to read a certain elements
contents from an XML file. Heres what I've come up with so far, which
seems
to get stuick in a loop (ASPNET.EXE hogs the CPU until I kill it!)

Public Function GetPageName(ByVal XMLFileName As String) As String
Dim XmlReader As New
XmlTextReader(Session("DataLocation").ToString
& XMLFileName)

XmlReader.Read()
While Not XmlReader.EOF
If XmlReader.Name = "Title" Then
Return XmlReader.ReadString()
End If
End While

'Return XmlReader.ReadElementString("Title")
XmlReader.Close()
End Function
Note that session("datalocation") is a full path.

Thanks,
Simon.
--
I am using the free version of SPAMfighter for private users.
It has removed 2168 spam emails to date.
Paying users do not have this message in their emails.
Try www.SPAMfighter.com for free now!


Nov 19 '05 #3
You need to move to the next elmennt using the read method. the code
you have is always reading the same node.

Try:

While XmlReader.Read()
If XmlReader.Name = "Title" Then
Return XmlReader.ReadString()
End If

End While

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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...
6
by: Raymond Hettinger | last post by:
Found in a pamphlet at a pre-school: --------------------------------------- Reading improves vocabulary Reading raises cultural literacy through shared knowledge Reading develops writing skills...
4
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # to open a file and write to file # do f=open('xfile.txt','w') # this creates a file "object" and name it f. # the second argument of open can be
24
by: Hendrik Schober | last post by:
Hi, I have a 'std::istream' and need to read its whole contents into a string. How can I do this? TIA; Schobi
19
by: Lionel B | last post by:
Greetings, I need to read (unformatted text) from stdin up to EOF into a char buffer; of course I cannot allocate my buffer until I know how much text is available, and I do not know how much...
4
by: Oliver Knoll | last post by:
According to my ANSI book, tmpfile() creates a file with wb+ mode (that is just writing, right?). How would one reopen it for reading? I got the following (which works): FILE *tmpFile =...
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...
3
by: Nick | last post by:
I have found a class that compresses and uncompresses data but need some help with how to use part of it below is the deflate method which compresses the string that I pass in, this works OK. At...
9
by: Mike Reed | last post by:
I must be having a "senile" day! I cannot recall, nor get to work, code to read a cookie's expiration date/time in an ASP page/VBScript. What am I missing? *** Sent via Developersdex...
4
by: Gaijinco | last post by:
I had a file named nap.in which looks like this: 4 10:00 12:00 Lectures 12:00 13:00 Lunch, like always. 13:00 15:00 Boring lectures... 15:30 17:45 Reading 4 10:00 12:00 Lectures 12:00 13:00...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.