title: Conversion from jQuery XML Object to String throws Security Error
body: <p>I have a XML Object generated by jQuery from the response of a REST Webservice:</p>
  
  <pre><code>$.ajax({
      type: "GET",
      url: "http://localhost:9299/foo",
      success:function(xml) {
          xmlDoc = $.parseXML(xml);
          $xml = $(xmlDoc);
          // The rest of the code manipulates the structure of the XML
      }
  });
  </code></pre>
  
  <p>Now I need to output the altered XML Object as a String. I've already found this solution for Firefox and other browsers:</p>
  
  <pre><code>out = new XMLSerializer().serializeToString($xml);
  </code></pre>
  
  <p>But all I get here is the following error message:</p>
  
  <pre><code>[Exception... "Security error"  code: "1000" nsresult: "0x805303e8 (NS_ERROR_DOM_SECURITY_ERR)"  location: "http://localhost/bar"]
  </code></pre>
  
  <p>All files I need are on localhost (including the webservice which provides me the XML and the jQuery library)</p>
  
  <p>Any ideas would be highly appreciated</p>
  
  <p><strong>Edit:</strong> </p>
  
  <p>I've simplified the problem and tried the following code:</p>
  
  <pre><code>$xml = $('&lt;?xml version="1.0"?&gt;&lt;root&gt;&lt;element&gt;bla&lt;/element&gt;&lt;element&gt;blubb&lt;/element&gt;&lt;/root&gt;');
  $xml.find("element").each(function() {
      alert($(this).text());
  });
  out = new XMLSerializer().serializeToString($xml);
  </code></pre>
  
  <p>Even without any webservice call the problem remains the same. (The alert outputs the content correctly)</p>
  
  <p><strong>Edit 2:</strong></p>
  
  <p>Thanks to the comment by Kevin B, I've got a working solution:</p>
  
  <pre><code>$.ajax({
      type: "GET",
      url: "http://localhost:9299/foo",
      dataType: 'xml',
      success:function(xml) {
          var $xml = $(xml);
          // The rest of the code manipulates the structure of the XML
      }
  });
  </code></pre>
  
  <p>The last line doesn't change:</p>
  
  <pre><code>out = new XMLSerializer().serializeToString($xml);
  </code></pre>