Xpath problem
-
Hi, I am trying to get list using xpath data[a='1']/a. Here is the xml <data> <a>h</a> <a>2</a> <a>56</a> <a>4</a> <a>1</a> </data> I am not getting desired result say <a>1</a> node rather that I am getting all the nodes. We can check xpath from here http://chris.photobooks.com/xml/default.htm[^]
-
Hi, I am trying to get list using xpath data[a='1']/a. Here is the xml <data> <a>h</a> <a>2</a> <a>56</a> <a>4</a> <a>1</a> </data> I am not getting desired result say <a>1</a> node rather that I am getting all the nodes. We can check xpath from here http://chris.photobooks.com/xml/default.htm[^]
Your XPath is selecting all 'a' child nodes of the 'data' node that has an 'a' child node with content '1' - the predicate is applied to the 'data' node selection, whereas you want the predicate to be applied to the 'a' node selection. Like this: data/a[text()='1']
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!