Hi Toby

> A Comparator would be nice in the meantime.

I've checked in a NodeComparator class in the org.dom4j.util pacakge in CVS.
It should show up soon in a daily build.
The org.dom4j.TestClone JUnit test uses it to verify equality of cloned
documents and elements. (I also check that changing an attribute value or
adding some text content to a leaf node means the documents are no longer
equal too ;-)


> Ok, But as a already mentioned above it is only a minor chracteristic.
> Althoug it would provide clearer colde.
> ((Element)root.getElements().get(2)).getText();
> is no so easy to read...

Agreed. Generics does help code readability much more than anything else.
Though I like XPath for this too...

Even without the cast, compare...

    root.elements().get(2).getText();

with

    root.valueOf( "foo[2]" );

The XPath version of the above code gets more and more cleaner as the
navigation path gets more complex. e.g.

    root.elements("foo").get(2).element("bar").attributeValue( "name" );

or

    root.valueOf( "foo[2]/bar/@name" );

James



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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

Reply via email to