I want to create a search in VB.Net for all XML Filenames that meet the Search Criteria entered by a user. The User can enter information in any of four textboxes.
I have a form in VB.Net that has the four textboxes named:
So, for example, if the User enters:
1234 for the Customer Number
Podunk for the City
Allen as the Associate
The result is a list of XML filenames that meet this criteria. In the example with the data below, the result would be:
The XML data below is in the file: Podunk_1234_May232013.XML
The XML contents of the following filename: Burgville_1234_April152013.XML
My search Function works for a single search term fine using the following function (some parts are redacted for this post - but it works).
Private Function FileSearch(ByVal Filename as String, ByRef ResultText As String) as Boolean
Dim xDoc As New XmlDocument
Dim xNodes As XmlNodeList
xNodes = xDoc.SelectNodes("CustomerNotes")
Dim xNode As XmlNode
Dim FindCustomerNumber As String
Dim SearchString As String = ""
Dim Result As Boolean = False
ResultText = ""
For Each xNode In xNodes
SearchString = xNode.InnerText
If SearchString.IndexOf(FindCaseNum) >= 0 Then
Result = True
ResultText = xNode.OuterXml
If Result=False Then
ResultText = "No Files Found"
My question is - what methods would you recommend to be able to search an XML file (Innertext) for multiple search criteria? Having Nested loops seems just too messy (and possibly slow) with as many as 5 Search fields...