XMLSerializer

  • 版本网址缩略名: XMLSerializer
  • 版本标题: XMLSerializer
  • 版本 id: 342167
  • 创建于:
  • 创建者: ziyunfei
  • 是否是当前版本?
  • 评论

修订内容

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

修订版来源

<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 id="Methods" name="Methods">Methods</h3>
<div dir="ltr" id="serializeToString" style="text-align: left;"><strong>serializeToString </strong><br>
     Returns the serialized subtree of a string.
<dt>
</dt></div>
<div dir="ltr" id="serializeToStream" 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="Example" style="text-align: left;"><span style="font-size: large;">Example</span></div>
<pre class="brush: js"> var s = new XMLSerializer();
 var d = document;
 var str = s.serializeToString(d);
 alert(str);
</pre>
<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>
<h3 id="See_also" 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>
恢复到这个版本