XML and Ruby

This chapter focuses on some of the popular parsing options available for Ruby and XML including SAX and DOM, and open source parsers including XML Parser, NQXML, and PJEXML. SAX beats DOM in terms of memory requirements and forward-read speed, while DOM allows a developer to jump back and forth in an XML file, at a memory cost. DOM's storing of the XML tree allows for faster traversing when dealing with larger XML files. Since both APIs have fairly open architectures, they can both be used simultaneously without damaging one another. NQXML and PJEXML are true Ruby parsers that have been written completely in Ruby. While XML Parser and Libgdome-ruby have the ability to use a tried-and-true parser, NQXML and PJEXML load up faster since they don't have to rely on loading expat. Because they don't depend on expat, NQXML and PJEXML are also less segault-prone than the other parsers. Ruby for Sablotron and XSLT4R are two libraries that are available for XSLT, and which currently work with both Unix/Linux and Windows. Ruby for Sablotron requires the Sablotron parser, but XSLT4R is entirely Ruby based, giving it a speed edge. Neither of the parsers is 100 percent complete.