selecting tags by one of two attributes via xpath?

Y

yawnmoth

If I wanted to select all 'form' tags with an attribute of 'name'
being set to a specific value, I'd do this:

//form[@name=whatever]

What if, however, I wanted to select all 'form' tags with either an
attribute of 'name' or an attribute of 'id' being set to a specific
value?
 
M

Martin Honnen

yawnmoth said:
If I wanted to select all 'form' tags with an attribute of 'name'
being set to a specific value, I'd do this:

//form[@name=whatever]

What if, however, I wanted to select all 'form' tags with either an
attribute of 'name' or an attribute of 'id' being set to a specific
value?

form[@name = 'foo' or @id = 'bar']
does a logical or. Do you really want an either/or?
 
Y

yawnmoth

Martin said:
yawnmoth said:
If I wanted to select all 'form' tags with an attribute of 'name'
being set to a specific value, I'd do this:

//form[@name=whatever]

What if, however, I wanted to select all 'form' tags with either an
attribute of 'name' or an attribute of 'id' being set to a specific
value?

form[@name = 'foo' or @id = 'bar']
does a logical or. Do you really want an either/or?

Yup - want it to behave like <a name="..."> or <a id="...">. For
either of those, page.html#... goes to the same thing. Not sure what
would happen if you had an <a name="..."> and an <a id="..."> with the
same value, but yeah - I do indeed want or. No particular preference
on whether or not it's inclusive or exclusive...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top