yawnmoth wrote:
On Aug 18, 12:48 pm, yawnmoth <terra1...@yahoo.comwrote:
>//form[@name='$id' or @id='$id']//input
//form[@name='$id' or @id='$id']//select//option
I think that should probably be @name=$id unless you really are testing
for the literal string "$id".
>I can combine those with an or (|), but to make my code more concise,
would it be possible to reuse the //form[@name='$id' or @id='$id']
bit? Could I maybe do something like this, instead?:
//form[@name='$id' or @id='$id']//(input or select//option)
It would be useful if XPath had that ability.
>That doesn't work, but is there something similar that would? Or am I
going to have to duplicate the //form[...] part for each one?
I think //form[@name=$id or @id=$id]//input | /form[@name=$id or
@id=$id]//select/option will work/
"//form//*[name()='input' or name()='textarea']" work, but "//form//
*[name()='input' or name()='select//option']" doesn't...
name() is unimodal: it returns just the name of a single node, not the
path to it.
In XHTML, the option element type can only occur as the child of select
or optgroup, so unless you really want to rule out optgroups, just using
option on its own may be enough.
///Peter
--
XML FAQ:
http://xml.silmaril.ie/
///Peter