my2cents

19. November, 2006

Don’t push – pull!

Filed under: Java — frightanic @ 01:44

I recently had to teach/advise some fellow co-workers on XML parsing technologies (with Java). One of them knew nothing about XML at all – let alone XML parsing – the other was familiar with DOM and SAX basics. So, I started with a crash course on those both technologies, stressed their differences, AND introduced both of them to the XmlPull API.

In my opinion the XmlPull API which has led to StAX, the Streaming API for XML as per JSR-173, has not gained the recognition it deserves. Btw, check out the StAX crash course at Wikipedia for a neat introduction.

A “pull” based API that pulls relevant information from the XML tree – rather than “push”ing events as with SAX – lets you parse the document without the large memory consumption of a DOM and without the rather complicated event handling of SAX. It’s usually a very light API with some implementations specifically targeting J2ME applications. In my life as a software engineer I’ve seen too much abuse of DOM and SAX simply because people didn’t know that there are better alternatives available. I’ve found that XmlPull/StAX fits wonderfully for most use cases. It’s easy to learn & use, it’s extremly fast, and the memory footprint is minimal. What more do you want from an XML parsing API? Nothing more.

Advertisements

1 Comment

  1. you might also want to look at vtd-xml, the latest and most advanced XML processing API available today

    Comment by anon — 22. November, 2009 @ 23:42


RSS feed for comments on this post.

Blog at WordPress.com.

%d bloggers like this: