Since I wanted to time the latest libxml-ruby bindings versus Rexml and Hpricot, I went looking for pre-written benchmarks.

When using the benchmarks, I realized that libxml's DOM traversal api was awful. Two main issues:

* node.each would stop at text nodes, thus giving back incorrect results

* node.children.each actually iterated over a node's child's child, which was completely unintuitive.

So I cleaned up the DOM traversal code, added a #each method to the C Node class, and them moved a bunch of the C code to Ruby (like next?, prev?, etc). I also exposed a node#first method to match node#last, and deprecated node#child (which is the same as node#first). In the end there is a whole lot less code that works a lot better.

But I made one api change. node#children now returns an array of child nodes, as you would expect. I can't imagine anyone is actually using node.children.each because its completely unintuitive. If anyone thinks that is a bad idea, say so now.

I also added a new test suite (tc_xml_traversal.rb) for all these methods - previously they were untested.

Changes checked in.

Charlie


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
libxml-devel mailing list
libxml-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/libxml-devel

Reply via email to