Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XPath selecting elements afer one having a given text

Reply
Thread Tools

XPath selecting elements afer one having a given text

 
 
=?ISO-8859-1?Q?Une_B=E9vue?=
Guest
Posts: n/a
 
      02-22-2007
my xml fragment :

<select id='aId'>
<option>option 1</option>
<option>option 2</option>
[...]
<option>---?---</option>
<option>option n + 1</option>
<option>option n + 2</option>
[...]
</select>

and i want to set the class attribute of all the options to :

add if text() = '---?---' (the easiest case allready done) ;
odd if the position() of option is odd and the element is before the one
having text() = '---?---'
even if the position() is even and before '---?---'
odd_edited if position is odd and the element is after '---?---'
even_edited if position is even and after '---?---'


i did the easiest case like that :

add for xhtml://select[@id = 'aId']/xhtmlption[text() = '---?---']

i'm also able to choose odd/even position :

xhtml://select[@id = 'aId']/xhtmlption[not(text() = '---?---') and
((position mod 2) = 0)]

i knwo that to choose the elements before the element '---?---' i have
to do something like :

following-sibling:htmlption[text() = '---?---']

for the elements before '---?---' and preceeding-sibling for the
elements after.

BUT what i don't know exactly is how to add this rule to the firsts
above ???
--
Une Bévue
 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Une_B=E9vue?=
Guest
Posts: n/a
 
      02-22-2007
Une Bévue <(E-Mail Removed)> wrote:

> i knwo that to choose the elements before the element '---?---' i have
> to do something like :
>
> following-sibling:htmlption[text() = '---?---']
>
> for the elements before '---?---' and preceeding-sibling for the
> elements after.
>
> BUT what i don't know exactly is how to add this rule to the firsts
> above ???



this is as simple as :

....xhtmlption[not(text() = '--?--']) and ((position() mod 2) = 0) and
not(preceding:htmlption[text() = '--?--'])]

for those before '--?--' and even position
--
Une Bévue
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Home of page afer update DetailsView Mario ASP .Net 0 03-02-2009 08:40 AM
drop down calendar disappear afer postback Jeff ASP .Net 1 01-13-2009 10:48 AM
XPath for selecting elements which start with a text node??? Thomas Schmidt XML 7 07-19-2007 11:24 AM
Session Variables Cleared afer Server.Execute Phil Grimpo ASP General 5 01-28-2005 12:29 AM
Problem selecting a node with XPATH if attribute value contains backslashes - how to force XPATH string to be treated as literal? Alastair Cameron XML 1 07-08-2003 07:24 PM



Advertisments