Results 1 to 7 of 7

Thread: Xml Dom

  1. #1
    idover
    Guest

    Angry Xml Dom

    i'm currently learning all about the great wonders of the xml dom... but why the hell won't this code work?!?!

    Code:
    <%
    
    Set objXMLDoc = Server.CreateObject("Microsoft.XMLDOM")
    objXMLDoc.Load("note.xml")
    objXMLDoc.async=false
    
    Response.Write objXMLDoc.documentElement.nodeName
    
    For Each objNode in objXMLDoc.documentElement.childNodes
        ' do whatever
    Next
    
    Set objXMLDoc = Nothing
    
    %>
    i always get an "object required" error...

    thanks in advance!

  2. #2
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Shouldn't you set async to false before you load it? Otherwise you could be trying to access its elements before it's fully loaded.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  3. #3
    idover
    Guest
    thanks, josh... unfortunately, that wasn't the problem... i'm still getting the "object required" error... this is driving me nuts at this point... i know it's probably simple to resolve, but those usually present the biggest headaches...

  4. #4
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    What line is the error on?
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  5. #5
    idover
    Guest
    well... maybe i've figured out why the root element isn't found... i altered the code to read:

    Code:
    <%
    
    Set objXMLDoc = Server.CreateObject("Microsoft.XMLDOM")
    
    objXMLDoc.async=false
    
    If objXMLDoc.Load("note.xml") Then
    	Response.Write "XML Document Loaded."
    Else
    	Response.Write "XML Not Loaded."
    End If
    
    Set objRoot = objXMLDoc.documentElement
    
    'strFrom = objRoot.selectSingleNode("from").text
    
    'For Each objNode in objRoot
    	' do whatever
    'Next
    
    Set objXMLDoc = Nothing
    
    %>
    this is the source of the file note.xml:

    Code:
    <?xml version="1.0" ?>
    
    <note>
      <to>You</to>
      <from>Me</from>
      <message>This is a test.</message>
    </note>
    the result is, of course, 'XML Not Loaded'... what a pain... please help... at this point, i'd rather stab myself in the leg than deal with the xml dom...

  6. #6
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    How about if you change this:
    Set objXMLDoc = Server.CreateObject("Microsoft.XMLDOM")
    to this
    Set objXMLDoc = Server.CreateObject("MSXML.DOMDocument")
    or this
    Set objXMLDoc = Server.CreateObject("MSXML2.DOMDocument")

    Will it work any better?
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  7. #7
    idover
    Guest
    thanks again, josh... but it is still returning "XML Not Loaded."... i have no clue at this point... now where is that java book?...

Posting Permissions

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



Click Here to Expand Forum to Full Width