Hello,
I am relatively new to XML. I have a project where I need to validate a scanned code against a file. The project is a Windows CE pproject using Compact Framework 1.1. Currently the file is XML but it doesnt have to be.
I did it using an XML document and scanning through the nodes, it is pretty fast but not fast enough. The maximum number of elements it has to loop through is 3600 and that takes about 1.5-2 seconds. The customer wants it instantaneous.
Here is my code, I would appreciate any insight into a faster way to scan for these values. SQL CE is not an option.
'in a module so the object can be global to my application
public rdr as XmlTextReader
Public xmlDoc As New XmlDocument()
Public n As XmlNode
Public n1 As XmlNode
public found as Boolean = false
'search method
' Set n to the first node.
n = xmlDoc.DocumentElement.FirstChild
Do While found = false
' Set n1 to the first child node (a node).
n1 = n.FirstChild
Do While Not n1 Is Nothing
if n1.innertext = me.txtAutoCode.text
found = true
Exit Do
end if
n1 = n1.NextSibling()
Loop
n = n.NextSibling()
If n Is Nothing Then Exit Do
' A blank line.
Loop

fast XML file scan......
Bill Sullivan
Sam Bent
the reader itself is slower (not by much) on a CE device. What I ended up doing was loading the reader contents into an array up front, then doing a binary search on the array from then on when looking for values.
was about 10 times faster than what I had :)
Ralf Kornmann