James Britt

Maximum R&D

Transforming Xml the Rexml Pull Parser

April 2007

This is a Dr. Dobbs article published November 27, 2005

The canonical way to transform XML documents is to use XSLT. Both XML and XSLT are specifications issued by the W3C, with XSLT itself being a formulation of XML. There is a convenient consistency in this, but where this syntax may work well for defining document structure and content, it may not be a good fit for programming document transformation logic. While XSLT has the official stamp of approval from the W3C, it may not always be the best choice for transforming XML. This is more likely to be true if you are a developer for whom XML is simply yet another data format to be manipulated by a more conventional programming language. In this article, I use Ruby and its built-in XML pull parser to present an alternative approach to XML transformations. In the process, I briefly examine three types of XML parsers, take a look at Ruby’s pull-parser API, and finally present an application that reads in the XML content files and transforms them to an RSS 1.0 feed.

Feel the magic: http://www.ddj.com/dept/webservices/184406385