I have an input document from which I would like to search for an attribute in the fastest manner possible. Eg: below's a pretty silly example:
<PossibleSuspects>
<PossibleSuspect name="A" id="423" character="shady"/>
<PossibleSuspect name="B" id="423" character="normal"/>
<PossibleSuspect name="C" id="423" character="normal"/>
<PossibleSuspect name="A" id="423" character="shady"/>
</PossibleSuspects>
Basically, I want to get the name
attribute of rows where character
is shady. I am okay with the first such match (other's can be ignored/will have same name
).
I considered looping over the whole document and getting the first match vs doing a regex search after converting document to string.
Which would be faster?