almost the same I think:
Node1/Node2[./attrib='new attrib']
Main Topics
Browse All TopicsI know the path for selecting on an attribute is
/Node1/Node2[@attrib='new attrib']
what is the equivelent if I want to select on attrib when attrib is an element as in the following case:
<Node1>
<Node2>
<attrib>1234</attrib>
<attrib>5677</attrib>
</Node2>
</Node1>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
No, that's not the same. The part in the [] gives a condition, whereas the part before it selects the node. This means that
/Node1/Node2/attrib[.='new
selects an element named "attrib" which has the value (inner text) of "new attrib" and which is contained in a Node2, which in turn is contained in a Node1.
Node1/Node2[./attrib='new attrib'] (same as Node1/Node2[attrib='new attrib'])
selects a Node2 which has a subnode called "attrib" with the value "new attrib" and which is contained in a Node1.
As you can see, that is NOT the same. Not even almost.
Sorry I didn't mean to offend you mr. AvonWyss...
I'll make myself more clear, I wasn't replying to you, but replying to jjacksn.
In his example he DID want to select 'Node2' where 'Node2' has an attribute value of 'new attrib'.
selecting Node2 containing an element with the value 'new attrib', is almost the same syntax, except for leaving the @ out.
I think jjacksn didn't want to select the attrib element, but the Node2 containing the attrib with value 'new attrib'
Summary:
"/Node1/Node2[@attrib='new
selects Node2 containing an attribute value 'new attrib'
"/Node1/Node2[attrib='new attrib']"
selects Node2 containing an element value 'new attrib'.
Or to do it in a more qualified form:
"/Node1/Node2[./attrib/tex
selects Node2 containing an element value 'new attrib'.
Good luck, Wiebe
Hi jjacksn,
see the XPath reference on MSDN:
http://msdn.microsoft.com/
you can also use functions like comment() and processing-instruction()
thx, Wiebe
Business Accounts
Answer for Membership
by: AvonWyssPosted on 2004-10-19 at 00:51:04ID: 12345274
The XPath you posted does NOT select an attribute, but a Node2 element which is inside a Node1 element and which has an attribute named attrib with the given value.
attrib']
/Node1/Node2/attrib[.='new
may be what you are looking for.