473,325 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Help: How to use MSXML2.DOMDocument in ASP?

hb
Hi,

I need to use MSXML2.DOMDocument in my ASP page. The following is my code:

xml.asp:
=====
<%
dim sx
sx="<root><a>text1</a><b>text2</b></root>"
dim xd
set xd=Server.CreateObject("MSXML2.DOMDocument")
xd.loadXML(sx)
Response.write xd.hasChildNodes
%>

Somehow, xd.hasChildNodes return False, i.e. there is nothing in the xd. I
guess the
error was caused by missing the path of the MSXML2 library file. It seems
like the
code doesn't know where the MSXML2.DOMDocument is. But the code didn't
generate any error.

Would you please tell me what I did wrong here? What should I do to let the
code
know where the MSXML2 library file is?

Thank you

hb
Jul 19 '05 #1
3 29233
hb wrote:
Hi,

I need to use MSXML2.DOMDocument in my ASP page. The following is my
code:

xml.asp:
=====
<%
dim sx
sx="<root><a>text1</a><b>text2</b></root>"
dim xd
set xd=Server.CreateObject("MSXML2.DOMDocument")
xd.loadXML(sx)
Response.write xd.hasChildNodes
%>
What do you get when you do:
Response.Write xd.xml
?

Somehow, xd.hasChildNodes return False, i.e. there is nothing in the
xd. I guess the
error was caused by missing the path of the MSXML2 library file.


No, that's not the issue. First of all, CreatObject is not using the name of
a file: it is looking up the GUID for the class specified in the argument in
the Registry. If it can't find it, you will get a "cannot create object"
error. Since you are not getting that error, and since the loadXML method is
not generating an error, I think you can rule that out as the cause of your
problem.

I tried your code and it returned True for me, so I suspect there is a
version issue. Verify that you have MSXML 3.0 or higher installed on the web
server. You can get the latest version of the MSXML Parser at the Microsoft
website.

HTH,
Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #2
hb
Thank you

hb
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:ux**************@TK2MSFTNGP15.phx.gbl...
hb wrote:
Hi,

I need to use MSXML2.DOMDocument in my ASP page. The following is my
code:

xml.asp:
=====
<%
dim sx
sx="<root><a>text1</a><b>text2</b></root>"
dim xd
set xd=Server.CreateObject("MSXML2.DOMDocument")
xd.loadXML(sx)
Response.write xd.hasChildNodes
%>
What do you get when you do:
Response.Write xd.xml
?

Somehow, xd.hasChildNodes return False, i.e. there is nothing in the
xd. I guess the
error was caused by missing the path of the MSXML2 library file.


No, that's not the issue. First of all, CreatObject is not using the name

of a file: it is looking up the GUID for the class specified in the argument in the Registry. If it can't find it, you will get a "cannot create object"
error. Since you are not getting that error, and since the loadXML method is not generating an error, I think you can rule that out as the cause of your problem.

I tried your code and it returned True for me, so I suspect there is a
version issue. Verify that you have MSXML 3.0 or higher installed on the web server. You can get the latest version of the MSXML Parser at the Microsoft website.

HTH,
Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jul 19 '05 #3
You're welcome. I hope that means your problem is solved.

Bob Barrows

hb wrote:
Thank you

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: JP SIngh | last post by:
Hi All I am trying to write a recursive function to list the managers and his employees in a tree like sctructure Manager 1 Emp1 Emp1.1 Emp 1.2 Emp 2
12
by: Amanda | last post by:
I have tried everything with this! I get an error stating "Index was outside the bounds of the array" My code looks like this.... xmlDoc = New XmlDocument() xmlDoc.Load("xml.doc") xslDoc...
1
by: Kapil Shah | last post by:
Hello everybody, I am trying to develop code to use the correct version of XMLHTTP before using it to send SOAP envelope to WebService . The code I have written is as follows, function...
2
by: Adrian | last post by:
hi I had the following code (fragment) in a VB6 app, what should the XML bits look like in VB.Net? Thanks Public Sub XML_list(ByVal xml As String) Dim xmldom As MSXML2.DOMDocument
4
by: s_m_b | last post by:
Using w2k advanced server (test system is standard server) "Set objXML = Server.CreateObject("MSXML2.FreeThreadedDOMDocument") objXML.async = False objXML.setProperty "ServerHTTPRequest", True...
4
by: DaytonGary | last post by:
Please Help: I have this wonderful function that takes as input an XML as a string and an XSLT as a string and using the XSLT, transforms the XML returning the result... Public Function...
3
by: mandanarchi | last post by:
Sub test() Dim myHTTP As MSXML2.xmlhttp Dim myDom As MSXML2.DOMDocument Dim orderno, errormsg, lineerr, lineerrmsg As MSXML2.IXMLDOMNode Dim myxml As...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.