I need to return the id from the element for
all nodes that have a "Y" in the elements Item3
The right answer depends on the exact "rules"
for selecting nodes. It's not clear whether you
are always looking for
Item3B or if they are just examples
of the rule. I also assume that by "nodes have a
'Y' in the elements" you mean they have an
attribute value wich equals "Y".
If you are interested in exactly three element
nodes with exactly the names "Item3", "Item3A" and
"Item3B", and if the "Y" value can be on any
//*[self::Item3 or self::Item3A or
self::Item3B][@* = 'Y']
Else, if the rule only says that element names
must start with "Item3", use
If there are namespaces in your input XML
document, it would be safer to use the
local-name() function instead of
It seems you are also trying to match
attributes that start with a certain string:
As you can see,
You can't include a wildcard in an XPath
query like /Item3*[Q3*="Y"].
is not really true - there are "wildcards" (you
don't usually call them wildcards), but you need
the right syntax.