xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
[XOM-interest] Let Elements implement java.lang.Iterable
- From: Peter Ertl <pertl AT gmx.org>
- To: xom-interest AT lists.ibiblio.org
- Subject: [XOM-interest] Let Elements implement java.lang.Iterable
- Date: Mon, 10 Mar 2008 16:29:05 +0100
XOM is really nice :-)
However, on Java 5 it's really annoying that Element doesn't implement java.lang.Iterable
So code would not look like this:
final Builder parser = new Builder();
final Document doc = parser.build("http://www.heise.de/newsticker/heise-atom.xml ");
final Elements entries = doc.getRootElement().getChildElements("entry");
for(int i=0; i < entries.size(); i++)
{
final Element entry = entries.get(i);
// process rss entry
}
But like that:
final Builder parser = new Builder();
final Document doc = parser.build("http://www.heise.de/newsticker/heise-atom.xml ");
for(Element entry : doc.getRootElement().getChildElements("entry"))
{
// process rss entry
}
That's two lines less, one variable saved and *imho* better readability...
Also this is quite a common usecase
Implementation in Element should be a no-brainer
So would be great to see this in XOM :-)
Best Regards
Peter
-
[XOM-interest] Let Elements implement java.lang.Iterable,
Peter Ertl, 03/10/2008
-
Re: [XOM-interest] Let Elements implement java.lang.Iterable,
Elliotte Harold, 03/10/2008
- Re: [XOM-interest] Let Elements implement java.lang.Iterable, Randall R Schulz, 03/11/2008
- Re: [XOM-interest] Let Elements implement java.lang.Iterable, Dave Pawson, 03/11/2008
- Re: [XOM-interest] Let Elements implement java.lang.Iterable, Steve Loughran, 03/18/2008
-
Re: [XOM-interest] Let Elements implement java.lang.Iterable,
Elliotte Harold, 03/10/2008
Archive powered by MHonArc 2.6.24.