<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
I have been using jdom b8 for a while and now I just got the b9
version. I was unpleasantly surprised by a few changes. I had switched from
DOM to jdom for its ease of use and convenience. I now see that this convenience
is going away and I'm wondering why. Here are my concerns:<br>
<br>
First, I believe that deprecating removeChildren() in Element is not a good
idea. Removing all children from an element now requires 2 method calls and
the intermediate List object, instead of just one method call.<br>
<br>
Same goes for hasChildren(). It makes perfect sense to check whether an
Element has children with this method; why the extra burden of returning
a List and checking its size?<br>
<br>
Also, there are some features that would be quite useful (and/or convenient)
and that are not present in jdom. One would be a method getFirstChild() in
Element, which would return the first child. Again, I see no reason why users
should be forced to go through the List returned by getChildren() to find
what they need. Convenience methods is one of Java's most important features.<br>
<br>
Another one would be a method to retrieve a child of an Element with a given
name, no matter what depth it's at. For example, an element called "mat" could
be found in structures such as:<br>
<a><br>
<mat/><br>
</a><br>
or<br>
<a><br>
<b><br>
<c><br>
<mat/><br>
</c><br>
</b><br>
</a><br>
In order to get the <mat/> element from however deep it resides, I
had to implement the method:<br>
Element dig(Element from, String target) , which returns the first occurrence
of a child called "target" of the element "from", no matter the depth. I am
making heavy use of this method because I am not interested in any children
above the <mat/> element. It would be helpful if such a method existed
in jdom. I would provide the code if the method was accepted for inclusion.<br>
<br>
Other methods that I find essential for my work and might benefit users if
they were available in Element:<br>
getSiblings() - would return all the siblings of an element directly<br>
getSameNameSiblings() - as above, but only for siblings with the same
name<br>
getChild(String regex) and getChildren(String regex) to retrieve all
children that match a regular expression, not just a fixed name<br>
<br>
I have appreciated the flexibility of jdom over other APIs, but I would like
to see it provide more convenience for the user, which should definitely
make it the API of choice for xml processing.<br>
<br>
Cheers,<br>
Daniel<br>
<br>
</body>
</html>