This is my XML file: <FILEENTRY Format="xml" Last_Modified="2001-12-19T09:43:24" filename="booktest.xml" lock="false" open="false"> <KEYWORDS value="test"/> <KEYWORDS value="test2"/> </FILEENTRY> <FILEENTRY Format="xml" Last_Modified="2000-01-15T12:00:00" filename="Test1.xml" lock="false" open="false" > <KEYWORDS key='doug' value="hope"/> <KEYWORDS value="test"/> <KEYWORDS value="m1a1"/> </FILEENTRY>
What XPath expression would I use to retrieve the FILEENTRY Node, that matches the key value pair? I have used this but it is ignoring the second part: String xPathExp = "//FILEENTRY/KEYWORDS[@value='hope'] | //FILEENTRY/KEYWORDS[@key='doug1']"; although the first expression is true, the second is false, but it still returns the node that has the filename=Test1.xml, why is not using the and operator?
Mapraputa Is
Leverager of our synergies
Sheriff
Joined: Aug 26, 2000
Posts: 10065
posted
0
If you want to check for both conditions, you should use "and" "... FILEENTRY[./KEYWORDS/@value='hope' and ./KEYWORDS/@key='doug']"
I looked at an XPath tutorial and did not see where u could use AND.
David Peterson
author
Ranch Hand
Joined: Oct 14, 2001
Posts: 154
posted
0
Originally posted by Rob Bass: I looked at an XPath tutorial and did not see where u could use AND.
Oh well if your tutorial doesn't say where you can use AND then the spec must be wrong and the above poster must be wrong and this can't possibly work: ...KEYWORDS[@value='hope' and @key='doug'] David