Method: HTMLTree::Element#as_rexml_document
- Defined in:
- lib/web/htmltools/xpath.rb
#as_rexml_document(rparent = nil, context = {}) ⇒ Object
convert the given HTMLTree::Element (or HTMLTree::Document) into a REXML::Element or REXML::Document, ready to use REXML::XPath on. Note that this caches the tree; further changes to my tree will not be reflected in subsequent calls
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/web/htmltools/xpath.rb', line 29 def as_rexml_document(rparent = nil, context = {}) return @_rexml_tree if @_rexml_tree node = REXML::Element.new( tag, rparent, context ) attribute_order().each { |attr| node.add_attribute(attr, attribute(attr).to_s) } children().each { |child| childNode = child.as_rexml_document(node, context) } @_rexml_tree = node end |