Preserving order when copying elements using Deliverance / XPath
Posted
by Jon Hadley
on Stack Overflow
See other posts from Stack Overflow
or by Jon Hadley
Published on 2010-05-12T19:05:13Z
Indexed on
2010/05/13
14:44 UTC
Read the original article
Hit count: 275
deliverance
|css-selectors
How would I, using Deliverance & XPath (or CSS) selectors, select and copy list items .one and .three from each list below, but display them in the order of their parent list?
<ul id="a-wrapper">
<li class="one"></li>
<li class="two"></li>
<li class="three"></li>
<li class="four"></li>
</li>
<ul id="b-wrapper">
<li class="one"></li>
<li class="two"></li>
<li class="three"></li>
<li class="four"></li>
</ul>
c,d,e,f,g etc....
The catch is it needs to use a href rule, eg: <prepend href="/blah/deblah" content="#x" theme="#y" />
Using the following just lists all the .one elements, then all the .three elements.
<prepend href="/blah/deblah" content=".one" theme="#y" />
<prepend href="/blah/deblah" content=".three" theme="#y" />
© Stack Overflow or respective owner