tags:

views:

246

answers:

3

Hi,

I am working on an ASP site hosted using SUN One (used to be called Chillisoft) server. I am having trouble loading in an XML file, the code I am using is below

dim directory
set directory = Server.CreateObject("MSXML2.DOMDocument")

if(directory.load(Server.MapPath("directory.xml"))) then
     Response.Write("Loaded")
else
     Response.Write("NotLoaded")
    If directory.parseError.errorCode Then
        Response.Write( "Parse error" )
    end if
end if

My asp page and directory.xml are both in the same folder "/public_html/".

I think the problem might have something to do with the mappath not finding the file, but no errors are returned so not sure what to do.

Thanks

+1  A: 

I don't know much about Sun One but I do know it has a Bean that emulates MSXML.

Oridinarily, you would use:-

Set directory = Server.CreateObject("MSXML2.DOMDocument")
directory.async = false
directory.load(Server.MapPath("directory.xml")

Otherwise load returns immeadiately whilst the xml is loaded asynchronously.

It can't see how the code you have posted would not return something without error.

First diagnositic I would is:-

Response.Write(Server.MapPath("directory.xml"))

and then

Dim direcotory
Set directory = Server.CreateObject("MSXML.DOMDocument")
Response.Write(Not (directory Is Nothing))
AnthonyWJones
A: 

Thanks for the response.

set directory = Server.CreateObject("MSXML2.DOMDocument")
directory.async = false

The above code errors with "Type Mismatch" for the async line.

Set directory = Server.CreateObject("MSXML2.DOMDocument")
Response.Write(Not (directory Is Nothing))

returns true.

The code I originally posted returned "NotLoaded". I am at a bit of a loss.

Thanks again

A: 

The load likely returns false because it hasn't fully loaded the document yet. You need to find a way to set async to false. If the Sun One is emulating MSXML2.DOMDocument well then async should accept false but you could try -1 or Response.Write(directory.async) to get an idea of what it is originally set to.

AnthonyWJones