a cross-broswer solution for serialize xml dom

 1 function serializeXml(xmldom) {
 2 
 3         if (typeof XMLSerializer != "undefined") {
 4             return (new XMLSerializer()).serializeToString(xmldom);
 5         } else if (document.implementation.hasFeature("LS", "3.0")) {
 6             var implementation = document.implementation;
 7             var serializer = implementation.createLSSerializer();
 8             return serializer.writeToString(xmldom);
 9         } else if (typeof xmldom.xml != "undefined") {
10             return xmldom.xml;
11         } else {
12         throw new Error("Could not serialize XML DOM");
13         }
14     }

 

posted on 2013-05-18 00:54  雷音  阅读(132)  评论(0编辑  收藏  举报

导航