title: How to update a NodeSet
body: <p>I am trying to add one more <code>&lt;EventRouter&gt;</code> element in the following XML:</p>
  
  <pre><code>&lt;EventRouters&gt;
          &lt;EventRouter id="Important Events to Log File" class="com.cyclonecommerce.events2.router.LogFileRouter" active="true"&gt;
              &lt;Parameters file="../logs/%nodeName%_events.log"
                          rollOnStart="false" autoFlush="true"
                          maxFileSize="2M" maxBackupFiles="5"/&gt;
              &lt;MetadataProcessorListRef ref="Messaging"/&gt;
              &lt;EventFilterRef ref="Important"/&gt;
          &lt;/EventRouter&gt;
          &lt;EventRouter id="Message Detail to Log File"   class="com.cyclonecommerce.events2.router.LogFileRouter" active="false"&gt;
              &lt;Parameters file="../logs/%nodeName%_message_detail.log"
                          rollOnStart="true" autoFlush="true"
                          maxFileSize="2M" maxBackupFiles="5"/&gt;
              &lt;MetadataProcessorListRef ref="Messaging"/&gt;
              &lt;EventFilterRef ref="Message Detail"/&gt;
          &lt;/EventRouter&gt;
  
  &lt;/EventRouters&gt;
  </code></pre>
  
  <p>I am able to append a node to a nodeset but after saving the XML I am not getting the updated XML I want:</p>
  
  <pre><code>require 'nokogiri'
  
  if File.exist?('a.xml')
    data = File.read("a.xml")
  
  end
  doc = Nokogiri::XML.parse data
  doc2=doc.xpath("//EventRouters/EventRouter")
  
  event_router = Nokogiri::XML::Node.new("EventRouter",doc)
  event_router['id'] = "some"
  param_node = Nokogiri::XML::Node.new("Parameters",doc)
  param_node.content = "some content"
  event_router &lt;&lt; param_node
  doc2&lt;&lt;  event_router
  
  File.open('test.xml', 'w') do |file|
    file.print doc.to_xml
  end
  </code></pre>