lib/hermod/xml_section.rb
def to_xml
      XML::Node.new(self.class.xml_name).tap do |root_node|
        # Add attributes
        attributes.each do |attribute_name, attribute_value|
          sane_value = sanitise_attribute(attribute_value)
          root_node[attribute_name] = sane_value if sane_value.present?
        end
        # Add child nodes
        self.class.node_order.each do |node_name|
          nodes[node_name].each do |node|
            root_node << node.to_xml
          end
        end
      end
    end
# Public: turns the XmlSection into an XML::Node instance (from
# libxml-ruby). This creates this as a node, adds any attributes (after
# sanitising them according to HMRC's rules) and then adds child nodes in
# the order they were defined in the DSL. Nodes that have been called multiple
# times are added in the order they were called.
#
# Returns an XML::Node
turns the XmlSection into an XML::Node instance (from
libxml-ruby). This creates this as a node, adds any attributes (after
sanitising them according to HMRC's rules) and then adds child nodes in
the order they were defined in the DSL. Nodes that have been called multiple
times are added in the order they were called.

Returns an XML::Node
turns the XmlSection into an XML :: Node instance ( from libxml - ruby ) . This creates this as a node adds any attributes ( after sanitising them according to HMRC ' s rules ) and then adds child nodes in the order they were defined in the DSL . Nodes that have been called multiple times are added in the order they were called . Returns an XML :: Node
def to_xml
      XML::Node.new(self.class.xml_name).tap do |root_node|
        attributes.each do |attribute_name, attribute_value|
          sane_value = sanitise_attribute(attribute_value)
          root_node[attribute_name] = sane_value if sane_value.present?
        end
        self.class.node_order.each do |node_name|
          nodes[node_name].each do |node|
            root_node << node.to_xml
          end
        end
      end
    end
def to_xml XML :: Node . new ( self . class . xml_name ) . tap do | root_node | attributes . each do | attribute_name , attribute_value | sane_value = sanitise_attribute ( attribute_value ) root_node [ attribute_name ] = sane_value if sane_value . present? end self . class . node_order . each do | node_name | nodes [ node_name ] . each do | node | root_node << node . to_xml end end end end
Public: turns the XmlSection into an XML::Node instance (from
libxml-ruby).
Public : turns the XmlSection into an XML :: Node instance ( from libxml - ruby ) .
# Add attributes # Add child nodes