Bkjia.com XML documentLet's take a look at a piece of code:
Reference content is as follows: Var doc = null; Var sdoc = null; Try { Doc = new ActiveXObject ("MSXML2.DOMDocument. 6.0 "); Sdoc = new ActiveXObject ("MSXML2.DOMDocument. 6.0 "); } Catch (e) { Alert (e. toString ()); } If (doc) Document. write ("OK "); Else Document. write ("fail ");
Doc. async = false; Doc. load ("http: // localhost/xml/a. xml "); Sdoc. async = false; Var r = sdoc. load ("http: // localhost/xml/a. xsl "); Try { // Var result = doc.transformNode(sdoc.doc umentElement );
Sdoc. setProperty ("SelectionNamespaces", "xmlns: xsl = 'HTTP: // www.w3.org/5o/#/transform '"); Var tmp = sdoc.doc umentElement. selectSingleNode ("xsl: template [@ mode = 'B']"); Alert (tmp. xml );
Var result = doc. transformNode (sdoc ); Alert (result ); // Document. write (result ); } Catch (e) { Alert (e. toString ()); } |
To use node selection and XSLT deformation in IE, use newActiveXObject ("MSXML2.DOMDocument. 6.0"); to generate an image (the subsequent version 6.0 varies depending on the specific environment ). In addition, in the loadxml document, if asynchronous LOAD is not used, set async to false. The deformation is still very simple. You can see the code above, when selecting a node, if there is a namespace, call the setProperty "SelectionNamespaces", "xmlns: xsl = 'HTTP: // www.w3.org/5o/xsl/transform'"); method, you can use the xpath with prefix: nodename to search for nodes. Otherwise, the nodes cannot be searched.