= libxml-bindings This introduction text is taken from http://thebogles.com/blog/an-hpricot-style-interface-to-libxml#, credit to Phil Bogle. == Convenience functions You can call to_xml_doc on any string to convert it into an XML::Document: >> s = 'p. boglecontentcont2' >> root = s.to_xml_doc.root The at() method returns the first Node matching the given xpath: >> root.at("author") => p. bogle The search() method returns a list of Nodes matching the given xpath: >> root.search("bar") => [content, content2] search() can also be called with a block to iterate through each of the matching nodes: >> root.search("bar") do |bar| puts bar.xpath; end /foo/bar[1] /foo/bar[2] == Namespace helpers The handling of default namespaces in libxml-ruby is awkward because you have to remember to pass along an array of namespace strings to every find() method call, and because you have to repeat yourself about the href of the default namespace. The helpers add a register_default_namespace function that makes this simpler. Suppose you had XML like the following Phil Bogle's Contacts ... Then you could say the following and have it work as expected: root.register_default_namespace("atom") root.search("atom:title") == Copyright Copyright (c) 2009 dreamcat4. See LICENSE for details. Copyright (c) 2008 Phil Bogle. See LICENSE for details.