Module XML
In: lib/s33r/libxml_extensions.rb

Convenience methods for libxml classes.

Methods

get_xml_doc   xget  

Classes and Modules

Class XML::Document
Class XML::Node

Public Class methods

Parse an XML string into an XML::Document instance.

[Source]

    # File lib/s33r/libxml_extensions.rb, line 19
19:   def XML.get_xml_doc(xml_str)
20:     parser = XML::Parser.new
21:     parser.string = xml_str
22:     parser.parse
23:   end

Public Instance methods

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.

[Source]

    # File lib/s33r/libxml_extensions.rb, line 9
 9:   def xget(xpath)
10:     nodes = self.find(xpath).to_a
11:     if nodes.empty?
12:       return nil
13:     else
14:       return nodes.first.content
15:     end
16:   end

[Validate]