Reputation: 319
I am having difficulty figuring out an XPath query that would allow me to return nodes based on the value of the Program attribute in the example below. For example, I would like to be able to search all nodes for a value of the Program attribute = "011.pas". I tried /Items/*[Program="012.pas"]
and also /Items/Item*[Program="01.pas"]
but neither works. What is the correct expression?
<Items>
<Item0 Program="01.pas"></Item0>
<Item1 Program="011.pas"></Item1>
</Items>
Upvotes: 0
Views: 402
Reputation: 167516
The attribute is selected with @Program
, the child elements of the Items
element with /Items/*
, so you want /Items/*[@Program = '011.pas']
.
Upvotes: 2