Hi all,

I've got an xml file that something like this:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<AllBanks xmlns="http://tempuri.org/BankNames.xsd">
	<Bank>
		<Name>MyBank</Name>
		<FromCode>000000</FromCode>
		<ToCode>051000</ToCode>
	</Bank>
	<Bank>
		<Name>Bank1</Name>
		<FromCode>090061</FromCode>
		<ToCode>092564</ToCode>
	</Bank>
	<Bank>
		<Name>Bank2</Name>
		<FromCode>100909</FromCode>
		<ToCode>199905</ToCode>
	</Bank>
	<Bank>
		<Name>Bank3</Name>
		<FromCode>200106</FromCode>
		<ToCode>291364</ToCode>
	</Bank>
	<Bank>
		<Name>Bank4</Name>
		<FromCode>301105</FromCode>
		<ToCode>337005</ToCode>
	</Bank>
</AllBanks>
Etc etc etc.

I am creating a function that where a BranchCode will be passed into it for eg: 35656

The function needs to search in which range does the passed variable reside, then return the Name field.

What would be the best way of doing this? Currently I constructed the following. (It's really crappy I know...)

VB Code:
  1. Function FindBankName(ByRef BranchCode As Object) As Object
  2.         Dim doc As New Xml.XmlDocument
  3.         Dim node As Xml.XmlNode
  4.         Dim child As Xml.XmlNode
  5.         Dim BankName As String
  6.  
  7.         BankName = ""
  8.         doc.Load(Environment.CurrentDirectory & "\banks.xml")
  9.         node = doc.DocumentElement
  10.         for each Child.selectSingleNode(child::Bank)
  11.             If (BranchCode >= node.SelectNodes(attribute::FromCode)) And (BranchCode <= node.SelectSingleNodes(Attribute::ToCode)) Then
  12.                 BankName = node.SelectNodes()
  13.             End If
  14.  
  15.         Next
  16.  
  17.  
  18.         'hard-code property value for testing
  19.         'child = node.SelectSingleNode(If (BranchCode >="00000") And (BranchCode <= "409999"))
  20.  
  21.  
  22.     End Function

I have never queried a XML file before, so this is my first try... Please Help