Results 1 to 3 of 3

Thread: Error with XML DOM object

  1. #1
    Join Date
    Jun 2005

    Error with XML DOM object

    So I'm finally trying to learn how to use xml and asp but am having an odd sort of a problem (well, it's odd to me, but I'm hoping it's something dumb I'm missing). I've stripped my problem down to the basics as such:

    here an .asp file:
    PHP Code:
    <% if 1=2 then %>


    set xmlDoc Server.CreateObject("Microsoft.XMLDOM")
    xmlDoc.async "false"

    getname xmlDoc.documentElement.getElementsByTagName("child").item(0).getAttribute("name")

    End Function
    html><head><title>test</title></head><body><%=getname("test.xml")%><br /><%=getname("test2.xml")%></body></html>

    <% else %>

    script type="text/vbscript">
    Sub getname(strURL)

    set xmlDoc CreateObject("Microsoft.XMLDOM")
    xmlDoc.async "false"

    End Sub

    </head><body><input type="button" onclick="getname('test.xml')"><br><input type="button" onclick="getname('test2.xml')"></body></html>

    <% end if %> 
    Now the way it's set up (with 1=2 at the head) it runs fine.. i get two buttons, clicking the top one gives me one name, and clicking the bottom gets me another... this is done client-side... now i want to do the same thing server-side (as in the example, display the names rather then call them up in a message box) so change 1=1 for what seems to me the equivalent server-side vbscript ... but when i try to pull that, i get the error message:

    Microsoft VBScript runtime (0x800A01A8)
    Object required: 'xmlDoc.documentElement'
    /<name>.asp, line 10
    I've been stuck on this more than I'd like to be, so I'm hoping someone can help out... below are the two .xml files:

    <?xml version="1.0" encoding="utf-8" ?>
    <child name="Sally"></child>
    <?xml version="1.0" encoding="utf-8" ?>
    <child name="Bobby"></child>
    This is an over-simplification of the master plan, so I'm looking for an answer moreso than "set up the whole thing differently" .. I specifically would like to parse out xml from multiple pages on the one ASP page, and need to be able to navigate those pages server-side, or else the tedium will drive me crazy

  2. #2
    Join Date
    Dec 2003
    England, UK
    if you're using asp then why are you doing the xml processing on the client-side? it would be better to do this kind of stuff on the server-side like the example below.

    test.xml = <%=getName("test.xml")%>
    test2.xml = <%=getName("test2.xml")%>
    function getName(xmldocpath)
    	on error resume next
    	getName = ""
    	set xmldoc = CreateObject("MSXML2.DOMDocument.4.0")
    	xmldoc.async = false
    	xmlDoc.resolveExternals = False
    	xmldoc.load server.mappath(xmldocpath)
    	if xmldoc.parseerror = 0 then
    		getName = xmlDoc.selectSingleNode("/parent/child/@name").value
    	end if
    end function
    Last edited by russell_g_1; 10-02-2005 at 10:37 AM.

  3. #3
    Join Date
    Jun 2005
    hmm... i'm thinking my problem might be that the XML I'm requesting is being dynamically generated through a different ASP page... I'm not sure why, then, at client-side the script is still able to extract the data but it fails at server-side... i'll see if i can set up an example...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles