how to use DomParser and Transform xml -xslt in ie9
-
Thursday, June 07, 2012 6:03 PM
Hi, I have found lot of links which uses following script to transform
Code 1
<script language="javascript">
function displayMessage() {
// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("site-index.xml")
// Load the XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("site-index.xsl")
// Transform
document.write(xml.transformNode(xsl))
}
</script>I want to rewrite the above code so that it can work on all the browser such as chrome,Firefox , IE9 .
So i will need to use xmlSerialization
I got a code for XMLSerialization which is as per following.
Code2
// Parse a string into an XML document
var parser = new DOMParser();var doc = parser.parseFromString("<myXML/>", "text/xml");
// Serialize any native DOM node to an XML string
// (including nodes from HTML documents)
var serializer = new XMLSerializer();
var xmlString = serializer.serializeToString(doc);I have two questions for code2
- can we use xml file directly instead of passing xmlstring(var doc = parser.parseFromString("<myXML/>", "text/xml");) or is there any way by which we can load xml file from local machine as shown in Code1 .
- in IE9 how we can transform xml-xslt as per given in Code1(document.write(xml.transformNode(xsl))).
Thanks....
Prashant
- Edited by prashantchavan Thursday, June 07, 2012 6:07 PM
All Replies
-
Thursday, June 07, 2012 11:47 PM
Post questions about html, css or scripting to the IE Web Developer forum. http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/threads with a link to your website or a mashup.
IETeam documentation can be found at the IE Developer center - http://msdn.microsoft.com/en-us/ie/aa740469.aspx
Rob^_^
- Proposed As Answer by doctoroftypeMVP Thursday, June 07, 2012 11:47 PM
- Marked As Answer by Leo HuangMicrosoft Contingent Staff, Moderator Wednesday, June 13, 2012 2:56 AM

