On Sat, 1 Jun 2002, Terry Steichen wrote:

> Could anyone explain how you are supposed to use selectNodes(Xpath1,
> Xpath2) such that Xpath2 results in a sorted node list?

I'm just guessing, as I've never useed it, but here's what I divine
from the javadocs...

xpath1 is used to select the set of nodes to be sorted.  It's the
normal 'xpath' paramter as in the simpler selectNodes(String xpath)
method.

The xpath2 parameter then, is used to select the key that's used
to perform the sorting, which I assume in only natural order of
strings.  (James? Does is handle numeric types, or anything?).

So, given:


<doc>
        <a name="foo"/>
        <a name="bar"/>
        <a name="cheese"/>
</doc>

And, given an Element representing the <doc> element, this

        docElem.selectNodes( "a", "@name" )

would produce a list of <a> elements sorted by the value of the
'name' attribute, producing:

        {
                <a name="bar"/>,
                <a name="cheese"/>,
                <a name="foo"/>,
        }

Hope that helps.  Heck, I hope it's an even marginally correct
explanation.

        -bob


_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm

_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to