Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] Let Elements implement java.lang.Iterable

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • 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






Archive powered by MHonArc 2.6.24.

Top of Page