Help: How to use MSXML2.DOMDocument in ASP?

Discussion in 'ASP General' started by hb, Sep 1, 2004.

  1. hb

    hb Guest

    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
     
    hb, Sep 1, 2004
    #1
    1. Advertising

  2. Re: 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.
     
    Bob Barrows [MVP], Sep 1, 2004
    #2
    1. Advertising

  3. hb

    hb Guest

    Re: How to use MSXML2.DOMDocument in ASP?

    Thank you

    hb
    "Bob Barrows [MVP]" <> wrote in message
    news:...
    > 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, Sep 2, 2004
    #3
  4. Re: 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"
     
    Bob Barrows [MVP], Sep 2, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jty202

    DomDocument

    jty202, Jan 16, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    542
    Peter Bromberg [C# MVP]
    Jan 17, 2005
  2. bird
    Replies:
    1
    Views:
    4,558
    William Park
    Mar 4, 2005
  3. Replies:
    4
    Views:
    465
    Joe Kesselman
    Nov 3, 2006
  4. K. Wilder
    Replies:
    1
    Views:
    575
    Dan Brussee
    Sep 16, 2003
  5. Replies:
    1
    Views:
    654
Loading...

Share This Page