471,863 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,863 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 28834
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by JP SIngh | last post: by
1 post views Thread by Kapil Shah | last post: by
2 posts views Thread by Adrian | last post: by
reply views Thread by YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

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.