I thought I had found an easy way with
doc.root.each_element_with_attribute('question') and that it would
return an array of all of the 'question' elements in the whole file.
But after much frustration I finally realized that it only returns the
elements with that attribute that are at that level - it doesn't
recurse through all the children in the file to find them all. Hard to
believe that there's not an option to have it recurse through all the
children, but maybe I haven't found it. The documentation on rexml
isn't that extensive and I had a hard time understanding some things
(of course that's also due to the the fact that I'm a n00b).
I've tried using XPath.match('question') but Xpath requires the path,
and like I said, these 'question' elements could be at any level,
depending on the XML file, so I'm not sure that that works either
(other than going through each level of the document "manually", but
that sucks).
Does anyone know of a simple way, using something like
each_element_with_attribute, to return an array of all of the elements
that match a certain attribute?
Thanks.