Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6594475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:48:59+00:00 2026-05-25T17:48:59+00:00

Something’s screwy here. I’m trying to parse this XSL file: <?xml version=1.0 encoding=utf-8?> <xsl:stylesheet

  • 0

Something’s screwy here. I’m trying to parse this XSL file:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Events</title>
</head>

<body>

    <dl>

    <xsl:for-each select="all/event">
        <xsl:sort select="substring(@displayuntil,7,4)" data-type="number" /> <!-- year  -->
        <xsl:sort select="substring(@displayuntil,1,2)" data-type="number" /> <!-- month -->
        <xsl:sort select="substring(@displayuntil,4,2)" data-type="number" /> <!-- day   -->

        <dt>
            <xsl:value-of select="@displayuntil" />
             -- 
            <xsl:value-of select="@title" />
        </dt>
        <dd>
            <xsl:value-of select="description" disable-output-escaping="yes" />
        </dd>

    </xsl:for-each>
    </dl>


</body>
</html>


</xsl:template>
</xsl:stylesheet>

Using the following JavaScript code, taken from w3schools:

function loadXMLDoc(dname) {
    if (window.XMLHttpRequest) {
        var xhttp = new XMLHttpRequest();
    } else {
        var xhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xhttp.open("GET",dname,false);
    xhttp.send();
alert(xhttp.responseText);    // displays the contents of the document
alert(xhttp.responseXML.xml); // in IE, displays nothing
    return xhttp.responseXML;
}

The xhttp.responseText alert displays my document, so I know it’s loading. The xhttp.responseXML.xml alert is blank, so apparently it isn’t a well-formed XML file.

I’ve run it through http://XMLvalidation.com and get no errors. So what have I overlooked?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:48:59+00:00Added an answer on May 25, 2026 at 5:48 pm

    It works for me.

    I just attached that javascript code to a button click, and put the xsl into a file on the server. When I clicked the button, I got two alerts, both with basically the same content.

    It may be that you are running into a stale cache. I ran into this just yesterday. I was using XHR to retrieve an XML file, and i was getting an old copy. If you’ve been changing the xsl, it could be the doc the web page retrieves is an old version, which could also be invalid. To avoid that , append ?_<random number> to the URL.

    Also you should declare your var at most once in a function. In Javascript, vars have function scope, so regardless where you put a var declaration, that variable name is known throughout the function. Which means it is good coding style to put all vars at the top of the function, regardless where you use them. In fact it is a conflict to declare a var with the same name in the if clause as well as the else clause; I don’t know what the JS engine will do about that, but it is strictly speaking not sensible. Easy to change though.

    EDIT – Lastly, you should use the updated ProgId. See this blog post from Microsoft for an explanation. Actually you don’t need the explanation, the short story is, Microsoft.XMLHTTP is wrong. What you should use is MSXML2.XMLHTTP.

    With those changes my code looks like this:

    function loadXMLDoc(dname) {
        var xhr = null, 
            d = new Date(), 
            noCacheUrl = dname + "?_=" + d.valueOf();
    
        // if the original document is mblase.xsl, then the "no cache" url will be 
        // sth like  mblase.xsl?_399383932 , where the number varies for each request.
        // The 'query string' will be discarded and you will get the same static file. 
        // This insures that you always get a fresh copy of the xsl document.
        if (window.XMLHttpRequest) {
          xhr = new XMLHttpRequest();
        } else {
          xhr = new ActiveXObject("MSXML2.XMLHTTP"); // current, correct ProgId
        }
        xhr.open("GET",noCacheUrl,false);
        xhr.send();
        alert(xhr.responseText);    // displays the contents of the document
        alert(xhr.responseXML.xml); // displays an indented version of the XSL document
        return xhr.responseXML;
    }
    

    If that no-cache trick doesn’t work then you need to diagnose further. If I were trying to diagnose this, I would simplify the XSL file – make it just an XML file, very simple, and see if you can get that to work. Then gradually add back complexity. That will allow you to avoid or rule out the invalid/malformed XML problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Something upgraded my Microsoft.Data.Entity.Design to version 10.6.10617.1. This broke some EntityFramework code generators which
Something similar to this question has been asked here - HTML/CSS Gradient that stops
Something like var life= { users : { guys : function(){ this.SOMETHING.mameAndDestroy(this.girls); }, girls
Something like this might had worked <%= Html.RouteLink(, new { controller = Article, action
Something like this: I am not sure how to code for this as I
Something I stumbled upon and made me wonder. Why does this work? void foo
Something is eluding me here. Every time I press the submit button, the form
Something is missing from the pro file it seems: TEMPLATE = app TARGET =
Something really basic here I fear. Have three sliders used to control the colour
Something like this: CREATE OR REPLACE FUNCTION get(param_id integer) RETURNS integer AS $BODY$ BEGIN

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.