Daniel Berger wrote:
> 
> Thank you James.
> 
> I have a followup issue.  There are some attributes that are optional,
> such as "interval".  If I try to use XPath in this fashion..
> 
> interval = parent.elements.to_a( "interval" )[0].text
> 
> ...and the "interval" node doesn't exist, it's going to raise a
> NoMethodError.  I *could* just rescue and ignore that error, but that
> doesn't seem very clean.  Is there a better way?  Or do I simply tell
> people they must include the optional tags, even if they're empty?

Question:  How much of your code is concerned with querying this data?

If you expect to read in the file once, and then run X number of queries 
against it, then you may be better off with a custom data structure.  Of 
course, this all depends on the size of X, the size of the data, 
requirements for updating or serializing the data, and so on.

I've poked around with reading in assorted XML and running queries 
against the resulting documents, and typically end up reading the XML 
into some other structure better suited for certain operation, like queries.

It's often much more efficient to read in the data using a stream or 
pull parser, and handing default values, optional elements/attributes, 
and the like as you encounter them, then to constantly run an XPath 
query on non-optimized data.

James