I am attempting to use XPath to query for a specific node
in the sample XML I've provided below.
I'm unsure of the exact XPath syntax, but I believe I
need the following query to get the proper node where the
node value contains a specific value:
/FYIFORM/TEMPLATEINFO/FIELD[@ID = "ODM_NAME"] = "THE FORM
I WANT"
Once I get a reference to this 'field' node, I can then
use the [MyNode.Parent] approach to navigate up to the
parent node. It's tHe 'DKey' attribute on that parent
node that I'm actually after. Also, I know there's
something like ANCESTOR:: or something that would make my
returned reference actually be the parent.. either
approach is fine by me... I was especially unsure of the
ancestor approach/syntax...
Once I have obtained the DKey for the template, I can
then use an additional XPath query to get
the 'SEARCHCLASS' field for that template who's value I
also require.
I believe the second XPath query I'll need is as follows:
/FYIFORM/TEMPLATEINFO[@DKEY=3110]/FIELD[@ID
= "SEARCHCLASS"]
Then the Node.Value here should be the actual 'search
class' I'm looking for...
Thanks for any help you can provide!
The sample XML:
<FYIFORM>
<TEMPLATEINFO DKEY="3110">
<FIELD ID="ODM_NAME">THE FORM I WANT</FIELD>
<FIELD ID="ODM_COMMENTS"></FIELD>
<FIELD ID="ODM_TITLE"></FIELD>
<FIELD ID="ODM_SUBJECT"></FIELD>
<FIELD ID="SEARCHCLASS">SearchClass1</FIELD>
</TEMPLATEINFO>
<TEMPLATEINFO DKEY="2835">
<FIELD ID="ODM_NAME">SOME OTHER FORM</FIELD>
<FIELD ID="ODM_COMMENTS"></FIELD>
<FIELD ID="ODM_TITLE"></FIELD>
<FIELD ID="ODM_SUBJECT"></FIELD>
<FIELD ID="SEARCHCLASS">SearchClass2</FIELD>
</TEMPLATEINFO>
</FYIFORM>