Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 351257 of XMLSerializer

  • Revision slug: XMLSerializer
  • Revision title: XMLSerializer
  • Revision id: 351257
  • Created:
  • Creator: istocode
  • Is current revision? No
  • Comment I changed Safari's compatibility from "unknown" to "3.0.4". I tested XMLSerializer all the way down to Safari 3.0.4 and it works.

Revision Content

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

 

For more information about using XMLSerializer in Firefox extensions, please see the documentation for nsIDOMSerializer.

Methods

serializeToString
Returns the serialized subtree of a string.
serializeToStream {{ non-standard_inline() }}{{ obsolete_inline("20") }}
The subtree rooted by the specified element is serialized to a byte stream using the character set specified.

Examples

 var s = new XMLSerializer();
 var d = document;
 var str = s.serializeToString(d);
 alert(str);

{{ non-standard_header() }} {{ obsolete_header("20") }}

 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");

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} 9.0 {{CompatVersionUnknown}} 3.0.4
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatUnknown}} {{CompatVersionUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

See also

Revision Source

<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>&nbsp;</p>
<p>For more information about using <code>XMLSerializer</code> in Firefox extensions, please see the documentation for <a href="/en-US/docs/nsIDOMSerializer" title="nsIDOMSerializer"><code>nsIDOMSerializer</code></a>.</p>
<h2 id="Methods" name="Methods">Methods</h2>
<dl>
  <dt id="serializeToString">
    serializeToString</dt>
  <dd>
    Returns the serialized subtree of a string.</dd>
  <dt id="serializeToStream">
    serializeToStream {{ non-standard_inline() }}{{ obsolete_inline("20") }}</dt>
  <dd>
    The subtree rooted by the specified element is serialized to a byte stream using the character set specified.</dd>
</dl>
<h2 id="Examples" name="Examples">Examples</h2>
<pre class="brush: js">
 var s = new XMLSerializer();
 var d = document;
 var str = s.serializeToString(d);
 alert(str);
</pre>
<p>{{ non-standard_header() }} {{ obsolete_header("20") }}</p>
<pre class="brush: js">
 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>
<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
<div>
  {{CompatibilityTable}}</div>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari (WebKit)</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>9.0</td>
        <td>{{CompatVersionUnknown}}</td>
        <td><span style="color: rgb(85, 85, 85); font-family: arial, sans-serif; font-size: 13px; line-height: 18px; background-color: rgb(248, 248, 248); ">3.0.4</span></td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Mobile</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
  <li><a href="/en-US/Parsing_and_serializing_XML" title="en-US/Parsing_and_serializing_XML">Parsing and serializing XML</a></li>
  <li><a href="/en-US/XMLHttpRequest" title="en-US/XMLHttpRequest">XMLHttpRequest</a></li>
  <li><a href="/en-US/DOMParser" title="en-US/DOMParser">DOMParser</a></li>
</ul>
Revert to this revision