Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Parsing error - JScript and ASP

Status
Not open for further replies.

tayorolls

MIS
May 8, 2007
42
US
Hi,

The intranet shows news by taking a feed from a URL. In case the URL is down, I would like to display a message indicating that the URL is down instead of crashing the intranet.

This is in JScript & ASP.

Code:
  /*********************************************
  CORE XMLHTTPREQUEST OBJECT
  Grabs an XML document, and converts it to a XMLDOM
  object so that it can be parsed with DOM methods.
  *********************************************/
  function getXMLObject(url) {
    var xmlhttp, xmldoc;

    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } 
      catch (E) {
        xmlhttp = false;
      }
    }
    xmlhttp.open("GET", url, false);
    //xmlhttp.send(null);    

    //Added Error Trapping in case the RSS Feed is down so that intranet does not crash.
  
    //Status of 200 means that the URL exists
    if (xmlhttp.status != 200) {
      Response.Write ("URL is down");    
    }
    else {
      xmldoc=Server.CreateObject("Microsoft.XMLDOM");
      xmldoc.async=false;
      xmldoc.loadXML(xmlhttp.ResponseText);    
      return xmldoc;
    }
    xmlhttp.send(null);    
  }

I get the error:

Code:
msxml3.dll error '80004005' 

Unspecified error 

/inc/RSSParserTest.inc, line 29

I call the above function in the following way:

Code:
<script language="JScript" runat="Server">

	// Create XML Object
	var rssURL = "[URL unfurl="true"]www.cnn1.com"[/URL]
	var newsURL = getXMLObject(rssURL);
	
</script>

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top