473,799 Members | 2,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stuck in neverland Loop Going nowhere

VS 2003 using VB.NET
I'm writing a program that reads text entries from a one file and matches
them against values in an XML document. However, the code seems to just sit
in the loop and never get anywhere, yet no errors occur. I tried this
hard-coding a title known to be in the XML file and it worked ok. It seems to
"hang" when the title is not found, but that's just a guess. Here is the code:

Imports System.Xml
Imports System.Text
Imports System.Xml.XPat h
Imports System.io

Public Class Form1
Inherits System.Windows. Forms.Form
Public ARList As New ArrayList ' holds the advanced reader text file
Public ARFile As String = "C:\accentdocs\ testinfo.exp"
Public ACCFile As String = "C:\accentdocs\ tlcrsi.xml"
Public Doc As XmlDocument = New XmlDocument
Public RootNode As New TreeNode("C:\")
Private Sub btnSubmit_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnSubmit.Click

Try
' set up the AR variables
Dim StartPos, TabPos As Integer
Dim Title As String
Dim ARLine As String
Dim srAR As System.IO.Strea mReader = New StreamReader(AR File)
Dim X As Integer, I As String
' set up the Accent variables and load document
Doc.PreserveWhi tespace = True
Doc.Load(ACCFil e)
Dim snode As XmlNode

' fill arraylist with AR titles
I = srAR.ReadLine ' throw away the first line of headings.
Do Until srAR.Peek() = -1 ' read AR file until EOF
ARLine = srAR.ReadLine 'grab entire row
TabPos = InStr(9, ARLine, vbTab) ' look for tab
ARList.Add(Mid( ARLine, 9, TabPos - 9)) ' extract title into list
Loop

Debug.WriteLine ("AR list filled: " & ARList.Count.To String)
Debug.WriteLine (ARList(0)) ' read the first entry

For Each arbk As String In ARList
Debug.WriteLine ("Looking for: " & arbk)
' HERE IS WHERE THE PROGRAM JUST STOPS, IT SEEMS
Dim root As XmlNodeList =
Doc.SelectNodes (".//mrcb[descendant::mrc b245-a='" & arbk & "']")
Debug.WriteLine (root.Count) ' there should only be a few hits
found
Dim book As XmlNode
For Each book In root ' There should only be a few
Debug.WriteLine (book.InnerText )
snode = book.SelectSing leNode(".//mrcb590-a")
snode.InnerText += ", GKA " & Now()
Debug.WriteLine ("Found: " & snode.InnerText )
Next
'MsgBox("Moving on to the next book!")
Next arbk

' When done, write out the revised XML document.
Doc.PreserveWhi tespace = True
Dim wtr As XmlTextWriter = New
XmlTextWriter(" C:\AccentDocs\R EVpmsrecs.xml", Encoding.Unicod e)
Doc.WriteTo(wtr )
wtr.Close()
Debug.WriteLine ("All done!")
Doc = Nothing

Catch ex As Exception
MsgBox(ex.Messa ge)
End Try
End
End Sub

Perhaps somebody sees something I'm doing wrong? I wanted to compile the
Xpath statements, but I don't think I can, since I have to recreate the
nodelist and node within each loop.
Thanks for any observations!
George
Nov 12 '05 #1
0 1086

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

Similar topics

3
5265
by: Anand Pillai | last post by:
This is for folks who are familiar with asynchronous event handling in Python using the asyncore module. If you have ever used the asyncore module, you will realize that it's event loop does not have a programmable exit condition. It keeps looping till the channels in its socket map (a dictionary) are closed and don't have any pending reads/writes. If you are using Python threads in your application, by using either the threading or...
12
4907
by: reynoldscraigr | last post by:
Hi All, hope someone can see what wrong here I have the following function function RemoveMenuFromHoldArray(menuName) { var i = 0; for (i=0;i<=MenusToHoldOpen.length-1;i++) { if (MenusToHoldOpen == menuName) { MenusToHoldOpen.splice(i,1); return;
9
2981
by: Nicolae Fieraru | last post by:
Hi All, I try to use Request.ServerVariables("HTTP_REFERER") in a script and I discovered it doesn't work as expected. I use XP with SP2 and I created a link on a web site which points to an asp page which should show the referer. I placed a link on www.eleader.com.au/linkref.html and there is a link pointing to www.monitortest.net/referer.asp When I use my computer with XP SP2, and I click on the first link, I get no referer. But when...
17
2038
by: JT | last post by:
Help me the following C++ question: Write a program to help a local bookshop automate its billing system. The program should do the following: (a)Let the user enter the ISBN, the system will trace the title and price of the book automatically. The system should check whether the book is in the stock or not. If it is not, please let the user to enter again. (b)Allow a customer to buy more than one item from the bookshop.
13
4123
by: na1paj | last post by:
here's a simple linked list program. the DeleteNode function is producing an infinit loop i think, but i can't figure out where.. #include <stdio.h> typedef struct { char *str; //str is a dynamic array of characters int length; //number of characters } String;
7
6089
by: RobKinney1 | last post by:
Hello, Wow...I have one for you all and hopefully I am not understanding this timer object correctly. I have a timer setup that pulses a connection through a socket every 60 seconds. But it seems recently connections just drop off because the timer stops firing. My question is if there is a timeout in the timer event that just shuts down the call if the timer event is taking too long to complete...?
7
1376
by: RallyDSM | last post by:
Hello, I'm currently trying to read a .CSV file and get all the data into an array so I can work with it in the program. Here is what I currently have. Private Sub IntializeData() Dim AL As New ArrayList
2
1679
by: hexusnexus | last post by:
I wrote a simple algorithm and it keeps getting stuck in a loop. I guess I'm just to tired to figure it out: compcount= suitrank= trump=2 l,lt=0,0 while l<4: while lt<4:
1
1649
by: Cainnech | last post by:
Hi guys, I'm a bit stuck in an infinite loop. What I'm trying to do in the code below is to compare two arrays and if there's an item in array ALGEMEEN that is not in array ITEMS, I want to add it to ITEMS. Now the ITEMS-array looks like this: items=;
0
9688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
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
10491
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...
1
10247
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10031
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...
1
7571
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
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();...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.