def write_nodes(writer, nodes)
      nodes.each_with_index do |node, idx|
        # write xml declaration if it exists.
        # TODO: Should throw somewhere if this isn't the first node.
        if node.is_a?(XmlDeclarationNode)
          writer.write('<?xml')
          write_attributes(writer, node)
          writer.write('?>')
          writer.new_line()
        elsif node.is_a?(XmlFragment)
          # if it's a fragment, just write the fragment, which is expected to be a string.
          writer.write_fragment(node.text)
        else
          # begin element tag and attributes
          writer.write('<' + node.name)
          write_attributes(writer, node)

          # if inner text, write it out now.
          if node.inner_text
            writer.write('>' + node.inner_text)

            if node.has_child_nodes()
              write_child_nodes(writer, node)
            end

            writer.write('</' + node.name + '>')
            crlf_if_more_nodes(writer, nodes, idx)
          else
            # Children are allowed only if there is no inner text.
            if node.has_child_nodes()
              # close element tag, indent, and recurse.
              writer.write('>')
              write_child_nodes(writer, node)
              # close the element
              writer.write('</' + node.name + '>')
              crlf_if_more_nodes(writer, nodes, idx)
            else
              # if no children and no inner text, use the abbreviated closing tag token unless no closing tag is required and unless self closing tags are not allowed.
              if node.html_closing_tag
                if writer.allow_self_closing_tags
                  writer.write('/>')
                else
                  writer.write('></' + node.name + '>')
                end
              else
                writer.write('>')
              end

              crlf_if_more_nodes(writer, nodes, idx)
            end
          end
        end
      end
      nil
    end
def write_nodes(writer, nodes)
      nodes.each_with_index do |node, idx|
        # write xml declaration if it exists.
        # TODO: Should throw somewhere if this isn't the first node.
        if node.is_a?(XmlDeclarationNode)
          writer.write('<?xml')
          write_attributes(writer, node)
          writer.write('?>')
          writer.new_line()
        elsif node.is_a?(XmlFragment)
          # if it's a fragment, just write the fragment, which is expected to be a string.
          writer.write_fragment(node.text)
        else
          # begin element tag and attributes
          writer.write('<' + node.name)
          write_attributes(writer, node)

          # if inner text, write it out now.
          if node.inner_text
            writer.write('>' + node.inner_text)

            if node.has_child_nodes()
              write_child_nodes(writer, node)
            end

            writer.write('</' + node.name + '>')
            crlf_if_more_nodes(writer, nodes, idx)
          else
            # Children are allowed only if there is no inner text.
            if node.has_child_nodes()
              # close element tag, indent, and recurse.
              writer.write('>')
              write_child_nodes(writer, node)
              # close the element
              writer.write('</' + node.name + '>')
              crlf_if_more_nodes(writer, nodes, idx)
            else
              # if no children and no inner text, use the abbreviated closing tag token unless no closing tag is required and unless self closing tags are not allowed.
              if node.html_closing_tag
                if writer.allow_self_closing_tags
                  writer.write('/>')
                else
                  writer.write('></' + node.name + '>')
                end
              else
                writer.write('>')
              end

              crlf_if_more_nodes(writer, nodes, idx)
            end
          end
        end
      end
      nil
    end
void write_nodes(XmlTextWriter writer, XmlNodes[] nodes)