Sha256: 13fbafe0de3f53870250c9f328b4224ae5a7cd12c604aa8b94f0a8337fb0787a
Contents?: true
Size: 848 Bytes
Versions: 3
Compression:
Stored size: 848 Bytes
Contents
require File.join(File.dirname(__FILE__), 'libxml_loader') # Convenience methods for libxml classes. module XML # Find first element matching +xpath+ and return its content # (intended for use as a mixed-in method for Document/Node instances). # # +xpath+: XPath query to run against self. # # Returns nil if no element matches +xpath+. def xget(xpath) nodes = self.find(xpath).to_a if nodes.empty? return nil else return nodes.first.content end end # Parse an XML string into an XML::Document instance. def XML.get_xml_doc(xml_str) parser = XML::Parser.new parser.string = xml_str parser.parse end # Make custom methods accessible to Document class. class Document include XML end # Make custom methods accessible to Node class. class Node include XML end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
s33r-0.5.1 | lib/s33r/libxml_extensions.rb |
s33r-0.4.2 | lib/s33r/libxml_extensions.rb |
s33r-0.5 | lib/s33r/libxml_extensions.rb |