JSFiddle - React, Tailwind, and code Playground

by prozoroff

JavaScript

txt = "<bookstore><book>";
txt = txt + "<title>Everyday Italian</title>";
txt = txt + "<author>Giada De Laurentiis</author>";
txt = txt + "<year>2005</year>";
txt = txt + "</book></bookstore>";

urlXML = 'http://www.w3schools.com/xsl/cdcatalog.xml';
urlXSL = 'http://www.w3schools.com/xsl/cdcatalog.xsl';

function processError(e)
{
    if(e.description)
        alert(e.description);
    else
        alert(e);
}

try {
    alert("try to get xml document from serialized string");
    alert(getXmlFromString(txt));
} catch (e) {
    processError(e);
}

try {
    alert("try to get xml document from url");
    var xml = getXmlFromUrl(urlXML);
    alert(xml.xml);
} catch (e) {
    processError(e);
}

try {
    alert("try to transform xml");
    var xml = getXmlFromUrl(urlXML);
    var xsl = getXmlFromUrl(urlXSL);
    var xmlString = "";
    var xslString = "";
    try {//IE11
        xmlString=(new XMLSerializer()).serializeToString(xml);
        xslString=(new XMLSerializer()).serializeToString(xsl);
    }
    catch (e) {
            try {//IE7
                xmlString=xml.xml;
                xslString=xsl.xml;
            }
            catch (e) {

            }
        }

    alert("XML: " + xmlString);
    alert("XSL: " + xslString);
   
    
    var win = window.open("", "Title", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=400, height=600, top="+(screen.height-800)+", left="+(screen.width-840));
    win.document.body.innerHTML = transformWithXSLT(xml,xsl);

    } catch (e) {
        processError(e);
}

function getXmlFromString(xmlData) {

    /// <summary>Returns xml document</summary>
    /// <param name="xmlData">Serialized xml string</param>
    /// <returns type="XmlDocument">xml document</returns>

    var xmlDoc;
    if (window.ActiveXObject) { // "ActiveXObject" in window - check for ie11
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async = "false";
       ...