Help: How to use MSXML2.DOMDocument in ASP?  
Author Message
ekrem





PostPosted: Wed Sep 01 14:31:36 CDT 2004 Top

ASP/Active Server Pages >> Help: How to use MSXML2.DOMDocument in ASP? 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

Web Programming450  
 
 
Bob





PostPosted: Wed Sep 01 14:31:36 CDT 2004 Top

ASP/Active Server Pages >> Help: How to use MSXML2.DOMDocument in ASP? 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.


 
 
hb





PostPosted: Thu Sep 02 08:02:57 CDT 2004 Top

ASP/Active Server Pages >> Help: How to use MSXML2.DOMDocument in ASP? Thank you

hb
"Bob Barrows [MVP]" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> 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.
>
>


 
 
Bob





PostPosted: Thu Sep 02 08:07:47 CDT 2004 Top

ASP/Active Server Pages >> Help: How to use MSXML2.DOMDocument in ASP? 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"