XmlDocument is not a database system. As soon as you say you don't want to
file to load and query individually yourself).
"Ken Getz" <ken.getz@gmail.com> wrote in message
news:uPhIXqB0FHA.3896@TK2MSFTNGP10.phx.gbl...
> Cool. Thanks. I appreciate the info. Got it working, using XPathNavigator.
> If the file is large, however, I don't want to load the whole thing -- it
> would be better to have a framework class stop loading once it found the
> correct node. Do you (or anyone else) have suggestions on how to optimize
> the lookup, with perhaps a simple code sample? Thanks. -- Ken
>
> "Martin Honnen" <mahotrash@yahoo.de> wrote in message
> news:OM6BEfB0FHA.2348@TK2MSFTNGP15.phx.gbl...
>>
>>
>> Ken Getz wrote:
>>
>>> Hi. I have an xml file in this format:
>>>
>>> <strings>
>>> <string>Item1</string>
>>> <string>Item2</string>
>>> <string>Item3</string>
>>> <string>Item4</string>
>>> </string>
>>
>> </strings>
>>
>>> I'm looking for the best way to search for a specific string, and return
>>> the index of its node within the strings element. That is, if someone
>>> enters Item3, I need the value 3 (or 2, if the index is 0-based).
>>
>> You can check the number of preceding siblings e.g.
>> /strings/string[. = 'Item3']/preceding-sibling::string
>> Of course XPath can count too
>> count(/strings/string[. = 'Item3']/preceding-sibling::string)
>>
>> --
>>
>> Martin Honnen --- MVP XML
>>
http://JavaScript.FAQTs.com/ >
>
>