Module: Doodle::XML::REXMLAdapter
- Included in:
- Doodle::XML
- Defined in:
- lib/doodle/xml.rb
Overview
adapter module for REXML
Instance Method Summary collapse
-
#get_root(doc) ⇒ Object
get the first XML element in the document.
-
#parse_xml(xml) ⇒ Object
return the parsed xml DOM.
-
#text_node?(node) ⇒ Boolean
test whether a node is a text node.
Instance Method Details
#get_root(doc) ⇒ Object
get the first XML element in the document
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/doodle/xml.rb', line 48 def get_root(doc) # skip :REXML::XMLDecl # REXML children does not properly implement shift (or pop) root = doc.children.find { |el, i| el.kind_of?(REXML::Element) } if root.nil? raise ArgumentError, "XML document does not contain any elements" else root end end |
#parse_xml(xml) ⇒ Object
return the parsed xml DOM
38 39 40 |
# File 'lib/doodle/xml.rb', line 38 def parse_xml(xml) REXML::Document.new(xml) end |
#text_node?(node) ⇒ Boolean
test whether a node is a text node
43 44 45 |
# File 'lib/doodle/xml.rb', line 43 def text_node?(node) node.kind_of?(::REXML::Text) end |