473,383 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

XPath selecting elements afer one having a given text

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']/xhtml:option[text() = '---?---']

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

xhtml://select[@id = 'aId']/xhtml:option[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::xhtml:option[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
Feb 22 '07 #1
1 2017
Une Bévue <un************@google.com.invalidwrote:
i knwo that to choose the elements before the element '---?---' i have
to do something like :

following-sibling::xhtml:option[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 :

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

for those before '--?--' and even position
--
Une Bévue
Feb 22 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Neil Zanella | last post by:
Hello, I would like to know whether the mozilla web browser has built in support for searching XML documents via XPath expressions as with IE's xmlobject's and xmlDoc's function selectNodes() or...
5
by: Tom Alsberg | last post by:
Hi there... I'm recently trying to get a bit acquainted with XML Schemas and XSL. Now, I have a few questions about XSL stylesheets and templates: * Is there a way to "enter" a child element...
2
by: Mike Kamermans | last post by:
I'm having some trouble using text() in an xsl:value-of xpath. I have the following xml: .... <graphemes> <grapheme>1</grapheme> <grapheme>2</grapheme> <grapheme>3</grapheme> </graphemes>...
1
by: Robert | last post by:
I am having a problem selecting nodes using the XMLnodelist Selectnodes using XPATH when I use XML SPY is successfully queries but when is use VB.net it comes up with nothing. Here is my code ...
2
by: nickheppleston | last post by:
I'm trying to iterate through repeating elements to extract data using libxml2 but I'm having zero luck - any help would be appreciated. My XML source is similar to the following - I'm trying to...
4
by: Claudio Calboni | last post by:
Hello folks, I'm having some performance issues with the client-side part of my application. Basically, it renders a huge HTML table (about 20'000 cells in my testing scenario), without content....
3
by: Arndt Jonasson | last post by:
Let's say we have a schema (maybe expressed in XML Schema, but not necessarily so), that allows this instance document: <top> <txt>This is text</txt> <books> <book>Tarzan</book> <book>Harry...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.