You could try something like this. Note: the context of the sorting XPath is the XPath's result.
try { SAXReader reader = new SAXReader(); Document document = reader.read( "file:sort.xml"); XPath xpath = DocumentHelper.createXPath("//item"); XPath sortXPath = DocumentHelper.createXPath("@name"); List nodes = xpath.selectNodes(document, sortXPath); for ( int i = 0; i < nodes.size(); i++) { System.out.println( ((Node)nodes.get(i)).asXML()); } } catch ( DocumentException e) { // the document is not well-formed. e.printStackTrace(); } The XML used was the following: <items> <item name="bbb"/> <item name="ccc"/> <item name="aaa"/> </items> Regards, Edwin -- http://www.edankert.com/ ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ dom4j-user mailing list dom4j-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-user