Section 15.1. Parsing XML with REXML


Chapter 15. Ruby and Data Formats

"Your information, sir," the Librarian says.

"Are you smart enough to tie that information into YOU ARE HERE?"

Hiro says.

"I'll see what I can do, sir. The formats appear to be reconcilable."

Snow Crash by Neal Stephenson

This is something of a "catch-all" chapter. Much of this material could have been placed elsewhere. The material is not all of equal importance or difficulty, but it is all important and needs to be covered somewhere.

It is a fact of life in computing that when information becomes complex enough, it always evolves its own "minilanguage" in which that information is best expressed. More often, it evolves multiple such minilanguages. We call these file formats or data formats.

Any of us could name hundreds of examples of file formats. There are image formats such as JPG, GIF, and PNG; document formats such as RTF and PDF; "universal" formats such as comma-separated, XML, or YAML; and countless thousands of proprietary data formats, many of which are variations on the fixed-column data storage so common in ancient times (meaning the 1960s).

One of the simplest, most common of data formats is plain text. Even if a file is simple text, however, it may have a structure imposed on it (hence the current popularity of XML). Other formats may be pure binary or some mixture of text and binary. So there are potentially "hierarchies" of formats just as the ISO networking model viewed information differently at different levels of networking.

No matter what format data is stored in, sooner or later we want to read it, parse it, and write it again. This chapter covers a few common file formats; there is no way to cover all of the common ones in a single book, however. If you want to parse such formats as vCard, iCal, or hundreds of others, you will have to do a search for the appropriate libraries (or you may have to write your own).




The Ruby Way(c) Solutions and Techniques in Ruby Programming
The Ruby Way, Second Edition: Solutions and Techniques in Ruby Programming (2nd Edition)
ISBN: 0672328844
EAN: 2147483647
Year: 2004
Pages: 269
Authors: Hal Fulton

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net