共用方式為


Getting Transformation Results as a DOM Document

 

The transformNodeToObject method provides a way to generate a new DOM document instead of XML text. The following code snippet uses data islands to load the XML source document and the style sheet. An empty data island is created to hold the results of the transformation.

<HTML>
  <SCRIPT FOR="window" EVENT="onload">
    data.transformNodeToObject(ss.XMLDocument, resultTree.XMLDocument);
  </SCRIPT>
  
  <XML id="data" src="portfolio.xml"></XML>
  <XML id="ss" src="portfolio.xsl"></XML>
  <XML id="resultTree"></XML>
</HTML>

Like the transformNode method, the transformNodeToObject method is applied to a node in the source tree, and accepts a style sheet in the form of a DOM tree. A second parameter contains another DOM Document node that will hold the result tree of the transformation.

Properties, that are set on the result tree object, such as validateOnParse and async, will apply during the transformation.