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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOM to load XML file

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi all,

I was unable to load the XML file generated with the ASP. Is it because the XML file MUST be raw XML data without the scripting to generate it. Can anyone help?

Below is the DOM page
--------------------------------------------------------
<%
' Load XML
Set source = Server.CreateObject(&quot;Microsoft.XMLDOM&quot;)
source.async = false
source.load(server.MapPath(&quot;xmlfile.asp&quot;))

Set source = Nothing
%>
---------------------------------------------------------

Below is the XML file genereate with ASP page (xmlfile.asp)
-----------------------------------------------------------
<%
'Generate XML through ASP
Response.ContentType=&quot;text/xml&quot;

Response.Write(&quot;<?xml version='1.0' ?>&quot;) & vbCrLf

Response.Write(&quot;<note>&quot;) & vbCrLf
Response.Write(&quot;<from>Jani</from>&quot;) & vbCrLf
Response.Write(&quot;<to>Tove</to>&quot;) & vbCrLf
Response.Write(&quot;<message>Lunch</message>&quot;) & vbCrLf
Response.Write(&quot;</note>&quot;) & vbCrLf
%>
-----------------------------------------------------------

Appreciate anyone to help.

Ant that crawl........
 
Hello,
The first possible problem is that MIME type &quot;text/xml&quot; is not set properly on your server.
See what MSDN says:
After setting this properly you should see results from xmlfile.asp as raw xml.
Second possible problem is using old Microsoft.XMLDOM instead of new MSXML2.DOMdocument.
May be there are also other problems.
Hope this helps
 
i see several problems but i can't tell what you want to do.

the first thing i see is you're trying to load an ASP into a DOM object. I know the code in &quot;xmlfile.asp&quot; creates a xml document, but it ISN'T an xml document, so it can't be loaded into a DOM object.

with the syntax you are using you should have a file called xmlfile.xml in the project directory and change it from source.load(&quot;xmlfile.asp&quot;) to source.load(&quot;xmlfile.xml&quot;)
or
you could use the loadXML method of the Dom object like this:
source.loadXML(&quot;<?xml version=&quot;1.0&quot;?> <note> <from>Jani</from> <to>Tove</to> <message>Lunch</message> </note>&quot;)

lastly i'm not sure what you're trying to do with the xml file once you have it loaded. you can do a response.write(source.xml) to test to see if it actually loaded into the DOM. (btw , you will have to view the source to see the tags, otherwise you will just see the data.)

i'm not sure if i helped you or confused you (or if you are even still looking for an answer, i guess this question is kinda old.) but let me know if i can do anything else.

VBBoB BoB
 
I have the same problem,
I need to load and asp because the asp generate the xml.
I tried the following bit it dosent work either.

<%
Dim xml
Dim xsl
Dim xdoc

set xml = Server.CreateObject(&quot;MSXML2.ServerXMLHTTP&quot;)
set xdoc = Server.CreateObject(&quot;MSXML2.DOMDocument&quot;)
set xsl = Server.CreateObject(&quot;MSXML2.DOMDocument.3.0&quot;)
xsl.async = false
xsl.load(Server.MapPath(&quot;px.xsl&quot;))
xdoc.async = false
xml.Open &quot;GET&quot;,&quot; false
xml.send()
set xdoc = xml.responseXML

set xml = nothing
set xdoc = nothing
set xsl = nothing
%>
 
Hi, I found your post and wondered whether you ever got an answer. We are having the same problem.
Let me know. Thx
stephane
sdubois@xignite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top