473,836 Members | 1,563 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(ByV al XMLFileName As String) As String
Dim XmlReader As New
XmlTextReader(S ession("DataLoc ation").ToStrin g
& XMLFileName)

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

'Return XmlReader.ReadE lementString("T itle")
XmlReader.Close ()
End Function
Note that session("datalo cation") 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 1201
XmlReader.Read( )
While Not XmlReader.EOF
If XmlReader.Name = "Title" Then
Return XmlReader.ReadS tring()
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******** ******@TK2MSFTN GP09.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(ByV al XMLFileName As String) As String
Dim XmlReader As New
XmlTextReader(S ession("DataLoc ation").ToStrin g
& XMLFileName)

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

'Return XmlReader.ReadE lementString("T itle")
XmlReader.Close ()
End Function
Note that session("datalo cation") 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***@msakadem ik.net> wrote in message
news:uL******** ******@TK2MSFTN GP10.phx.gbl...
XmlReader.Read( )
While Not XmlReader.EOF
If XmlReader.Name = "Title" Then
Return XmlReader.ReadS tring()
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******** ******@TK2MSFTN GP09.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(ByV al XMLFileName As String) As String
Dim XmlReader As New
XmlTextReader(S ession("DataLoc ation").ToStrin g
& XMLFileName)

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

'Return XmlReader.ReadE lementString("T itle")
XmlReader.Close ()
End Function
Note that session("datalo cation") 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.ReadS tring()
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
3596
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 is written ( commented out in code) then it reads in OK. However, when I move the code to the right place ( as shown here) it throws an IO exception. Both the Filter class and it's constituent class implement Serializable and it would seem the...
6
2416
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 Reading opens the mind to new ways of understanding Reading is fun Accordingly, I suggest the following works of literature:
4
3071
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
2771
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
10395
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 text is available until I have read it... which seems to imply that multiple reads of the input stream will be inevitable. Now I can correctly find the number of characters available by: |
4
9850
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 = tmpfile(); /* write into tmpFile */ ...
6
3804
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 trying to read a flatfile. In COBOL, my simple file layout and READ statement would look like below. Question: what is the standard, simple coding convention for reading in a flatfile - one record at a time?? SCANF does not work because of...
3
9518
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 the end of this message is the inflate method this is where I get stuck I know that I need a byte array but because I am decompressing a string I have no idea of how big the byte array will need to be in the end (the inflate and deflate methods...
9
5526
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 http://www.developersdex.com ***
4
3269
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 Lunch, just lunch.
0
9674
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10860
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10560
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10261
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9389
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6984
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4466
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4026
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.