http://www.rubynet.org/modules/xml/ruby-libxml/ruby-libxml-20020709.tar.gz
It’s functional, it’s young, it validates, it handles compressed
documents, it’s C, it’s quick (at least as far as XML parsers go), and
feature rich (or will be: I haven’t turned on XInclude, XPointer,
Schemas, DocBook, or a hand full of others that are available). The
biggest two things that libxml is lacking right now are documentation
and a more complete API: features are coming and there likely won’t be
any shortage of them. Here’s a sample script that shows some of the
API:
xd = XML::Document.file(‘some_xml_file.xml’)
xd.xpath_find(’/my/xpath/query’).each do |node|
puts "Filename: #{node.child(‘filename’)}"
puts "Mode: #{node.child(‘mode’)}"
puts "Content: #{node.child(‘content’)}"
end
And the corresponding test doc:
uga ble sweet uga ble sweetSimple for the most part.
If someone gets curious and runs the "document_self.rb"
script, they’ll notice a whole ton of methods. This API doesn’t hide
any of the internals of XML to the user, which is good and bad. For
example, in the xml bit “bar”, there are technically two
nodes there. The tag is one, and it’s contents is another. The
other interesting thing about this is that in the following XML block,
there are five nodes.
bar
asd
- bar
- [white space between and ]
- asd
While this is technically the correct behavior, it’s unintuitive to
most people and isn’t what they want. As a result, node.to_s is the
exact same as node.child.content. In the API, I’m making things nice
and friendly though so no one will notice (or so the theory goes).
Anyway, point being that there’s a lot of power at the moment for
those who want to have full access to the XML document.
Anyway, that’s my bit for now. I’m looking for new users/suggestions:
both are very welcome. -sc
···
–
Sean Chittenden