XMLSerializer

  • Revision slug: XMLSerializer
  • Revision title: XMLSerializer
  • Revision id: 127810
  • Created:
  • Creator: The Hunter
  • Is current revision? No
  • Comment

Revision Content

XMLSerializer can be used to convert DOM subtree or DOM document into text. XMLSerializer is available to unprivileged scripts.

XMLSerializer is mainly useful for applications and extensions based on Mozilla platform. While it's available to web pages, it's not part of any standard and level of support in other browsers is unknown.

Methods

serializeToString
Returns the serialized subtree in the form of a string
serializeToStream
The subtree rooted by the specified element is serialized to a byte stream using the character set specified.

Example

 var s = new XMLSerializer();
 var d = document;
 var str = s.serializeToString(d);
 alert(str);
 var s = new XMLSerializer();
 var stream = {
   close : function()
   {
     alert("Stream closed");
   },
   flush : function()
   {
   },
   write : function(string, count)
   {
     alert("'" + string + "'\n bytes count: " + count + "");
   }
 };
 s.serializeToStream(document, stream, "UTF-8");

References

  • http://www.xulplanet.com/references/objref/XMLSerializer.html

See also

{{ wiki.languages( { "fr": "fr/XMLSerializer" } ) }}

Revision Source

<p>
</p><p><code>XMLSerializer</code> can be used to convert DOM subtree or DOM document into text. <code>XMLSerializer</code> is available to unprivileged scripts.
</p>
<div class="note">
<p><code>XMLSerializer</code> is mainly useful for applications and extensions based on Mozilla platform. While it's available to web pages, it's not part of any standard and level of support in other browsers is unknown.
</p>
</div>
<h3 name="Methods"> Methods </h3>
<dl><dt>serializeToString
</dt><dd>Returns the serialized subtree in the form of a string
</dd><dt>serializeToStream
</dt><dd>The subtree rooted by the specified element is serialized to a byte stream using the character set specified.
</dd></dl>
<h3 name="Example"> Example </h3>
<pre class="eval"> var s = new XMLSerializer();
 var d = document;
 var str = s.serializeToString(d);
 alert(str);
</pre>
<pre class="eval"> var s = new XMLSerializer();
 var stream = {
   close : function()
   {
     alert("Stream closed");
   },
   flush : function()
   {
   },
   write : function(string, count)
   {
     alert("'" + string + "'\n bytes count: " + count + "");
   }
 };
 s.serializeToStream(document, stream, "UTF-8");
</pre>
<h3 name="References"> References </h3>
<ul><li> http://www.xulplanet.com/references/objref/XMLSerializer.html
</li></ul>
<h3 name="See_also"> See also </h3>
<ul><li> <a class="external" href="http://www.xulplanet.com/references/objref/XMLSerializer.html">Reference</a> (XULPlanet)
</li><li> <a href="en/Parsing_and_serializing_XML">Parsing and serializing XML</a>
</li><li> <a class="external" href="http://xulplanet.com/tutorials/mozsdk/xmlparse.php">Parsing and serializing XML</a> (XULPlanet)
</li><li> <a class="external" href="http://kb.mozillazine.org/Parsing_and_serializing_XML#Parsing_strings_into_DOM_trees">Parsing and serializing XML</a> (MozillaZine)
</li><li> <a href="en/XMLHttpRequest">XMLHttpRequest</a>
</li><li> <a href="en/DOMParser">DOMParser</a>
</li></ul>
{{ wiki.languages( { "fr": "fr/XMLSerializer" } ) }}
Revert to this revision