Module: XML
Overview
Convenience methods for libxml classes.
Defined Under Namespace
Class Method Summary collapse
-
.get_xml_doc(xml_str) ⇒ Object
Parse an XML string into an XML::Document instance.
Instance Method Summary collapse
-
#xget(xpath) ⇒ Object
Find first matching element and return its content (intended for use as a mixed-in method for Document instances).
Class Method Details
Instance Method Details
#xget(xpath) ⇒ Object
Find first matching element and return its content (intended for use as a mixed-in method for Document instances).
xpath
: XPath query to run against self.
Returns nil if no element matches xpath
.
9 10 11 12 13 14 15 16 |
# File 'lib/s33r/libxml_extensions.rb', line 9 def xget(xpath) nodes = self.find(xpath).to_a if nodes.empty? return nil else return nodes.first.content end end |