mozilla

Revision 127817 of XMLSerializer

  • Revision slug: XMLSerializer
  • Revision title: XMLSerializer
  • Revision id: 127817
  • Created:
  • Creator: Imphil
  • Is current revision? No
  • Comment 18 words removed

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 the Mozilla platform. While it is available for web pages, it's not part of any standard and level of support in other browsers unknown.
 

Methods

serializeToString
     Returns the serialized subtree 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");

See also

{{ languages( { "fr": "fr/XMLSerializer", "ja": "ja/XMLSerializer" } ) }}

Revision Source

<p> </p>
<div dir="ltr" id="result_box" style="text-align: left;">XMLSerializer can be used to convert DOM subtree or DOM document into text. XMLSerializer is available to unprivileged scripts.</div>
<p><code> </code></p>
<div class="note">
<div dir="ltr" style="text-align: left;">XMLSerializer is mainly useful for applications and extensions based on the Mozilla platform. While it is available for web pages, it's not part of any standard and level of support in other browsers unknown.</div>
<div dir="ltr" id="result_box" style="text-align: left;"> </div>
</div>
<h3 name="Methods">Methods</h3>
<div dir="ltr" id="result_box" style="text-align: left;"><strong>serializeToString </strong><br>
     Returns the serialized subtree of a string.<dt><br>
</dt></div>
<div dir="ltr" id="result_box" style="text-align: left;"><strong>serializeToStream </strong></div>
<div dir="ltr" style="text-align: left;">     The subtree rooted by the specified element is serialized to a byte stream using the character set specified.     </div>
<div dir="ltr" id="result_box" style="text-align: left;"><span style="font-size: large;">Example</span></div>
<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="See_also">See also</h3>
<ul> <li><a href="/en/Parsing_and_serializing_XML" title="en/Parsing_and_serializing_XML">Parsing and serializing XML</a></li> <li><a href="/en/XMLHttpRequest" title="en/XMLHttpRequest">XMLHttpRequest</a></li> <li><a href="/en/DOMParser" title="en/DOMParser">DOMParser</a></li>
</ul>
<p>{{ languages( { "fr": "fr/XMLSerializer", "ja": "ja/XMLSerializer" } ) }}</p>
Revert to this revision