Error reading XML file

Posted on 2004-09-07
Last Modified: 2010-05-18
I am trying to read and display the contents of an XML file. (I want to restructure the output too using Javascript but I can't get past this first hurdle)

This is the error:
Response object error 'ASP 0185 : 80020003'

Missing Default Property

/displayxml.asp, line 30

A default property was not found for the object.

Here is the Code:
  var xmlDoc = new ActiveXObject("MSXML.DOMDocument");
  var sourceFile = Server.MapPath("xml_file.xml");  
  function loadXML(xmlFile)

function verify()
 // 0 Object is not initialized
 // 1 Loading object is loading data
 // 2 Loaded object has loaded data
 // 3 Data from object can be worked with
 // 4 Object completely initialized
 if (xmlDoc.readyState != 4);
   return false;

Response.ContentType = "text/html";

Response.Write(xmlObj); //This is line 30

I know that I should use Response.ContentType = "text/xml"; but I need to get past this ASP error first which is only displayed using text/html

Can anyone spot the problem ?
Question by:Milkybar-kid
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 15

Expert Comment

ID: 12002360

Author Comment

ID: 12003998
I had already tried that. I get the message

Microsoft JScript runtime error '800a01a8'

Object required

/displayxml.asp, line 30
LVL 15

Accepted Solution

Thogek earned 500 total points
ID: 12007751
Which suggests that xmlObj is not being correctly populated.  I'd suggest two things:

To be safe, you should declare xmlObj outside of the functions, just to ensure that xmlObj is a global (not method) variable.  Something like

    var xmlDoc = new ActiveXObject("MSXML.DOMDocument");
    var sourceFile = Server.MapPath("xml_file.xml");  
    var xmlObj = null;  // declared as global-scope variable

    function loadXML(xmlFile)

The DOMDocument.loadXML expects to be passed a string containing XML-formatted data.  If you want to load the XML contained within a file whose pathname you will pass to the function, use the load method instead.  I.e.,

    function loadXML(xmlFile)
        xmlDoc.load(xmlFile);  // load XML from file


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question