First, you need to understand how to dynamically load xml files. You can use XMLDOM objects, XMLHttpRequest, and responseXML objects. Here I use XMLHttpRequest.
1. Use XMLDOM or XMLHttpRequest to load xml and xslt.
2. Use ttprocessor. importStylesheet to introduce XSLT.
3. Use the effectprocessor. transformToFragment method to convert it to the DOM Fragment. Then, appendChild or insertBefore is used to append or insert the fragment element of the DOM.
Var ownerDocument = document. implementation. createDocument ("", "test", null );
Var newFragment = processor. transformToFragment (domToBeTransformed, ownerDocument );
Of course, you can also use transformToDocument
Var newDocument = processor. transformToDocument (domToBeTransformed );
It should be noted that the converted node is an Element or a segment, so obj. innerHTML = new Document can be used only after the serialization below
(New XMLSerializer (). serializeToString (newDocument)
5. In IE, the XMLDOM method and xmldoc. transformNode (document) method can be used for the transformation.
First, we need to create an XML file and An XSLT file to facilitate subsequent explanations.
Content is here