Class: HrrRbRelaxedXML::Document

Inherits:
REXML::Document
  • Object
show all
Defined in:
lib/hrr_rb_relaxed_xml/document.rb

Instance Method Summary collapse

Instance Method Details

#add(child) ⇒ Object Also known as: <<



8
9
10
11
12
13
14
15
16
17
# File 'lib/hrr_rb_relaxed_xml/document.rb', line 8

def add child
  case child
  when REXML::XMLDecl, REXML::DocType
    super
  else
    child.parent = self
    @children << child
    child
  end
end

#add_element(element, attrs = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/hrr_rb_relaxed_xml/document.rb', line 20

def add_element element, attrs={}
  if element.nil?
    super
  else
    child_e = @elements.add element
    attrs.each do |k, v|
      child_e.attributes[k] = v
    end
    child_e
  end
end