Solved

XMLDom not working in standalone vbscript

Posted on 2004-03-23
10
543 Views
Last Modified: 2012-05-04
Hello
I've got an ASP vbscript that works ok. Here it is:

Dim objXMLDOM
Set objXMLDOM = Server.CreateObject("Microsoft.XMLDOM")

objXMLDOM.load(Server.MapPath("test.xml"))

For Each objChild In objXMLDOM.documentElement.childNodes
      Response.Write objChild.NodeName & " - "   
      Response.Write objChild.Text & "<BR>"
Next
Next

However, I cannot get this to work in a standalone vbscript (test.vbs) that looks like this:

Dim objXMLDOM
Set objXMLDOM = CreateObject("Microsoft.XMLDOM")

objXMLDOM.load("c:\test.xml")

For Each objChild In objXMLDOM.documentElement.childNodes
      MsgBox objChild.NodeName & objChild.Text
Next
Next

It throws an "Object Required" error. I know the file is there since a fileexist returns true.

Please help,

Soren
0
Comment
Question by:speder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
10 Comments
 
LVL 26

Accepted Solution

by:
Rejojohny earned 125 total points
ID: 10664887
try this ...
objXMLDOM.async = false
objXMLDOM.load("c:\test.xml")
if objXMLDOM.parseError <> 0 then  'to catch the error if any
          msgbox "Error in loading"
end if
0
 

Author Comment

by:speder
ID: 10664920
This returns Error in Loading but the file is there since this returns "file is there". The xml-file should be okay since it loads allright in an ASP page (and I'm able to traverse the dom tree, etc.)

Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")

Dim objXMLDOM
Set objXMLDOM = CreateObject("Microsoft.XMLDOM")
objXMLDOM.async = false

objXMLDOM.load("C:/test.xml")

if objXMLDOM.parseError <> 0 then  'to catch the error if any
          msgbox "Error in loading"
end if

if objFSO.fileExists("C:/test.xml") then
      msgbox "file is there"
end if
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 10664997
if it gives .. error in loading .. then there must be some error in the XML file like tags not matching or closing tag not present .. note that XML is case sensitive too ...

change ur code to get the actual error

if objXMLDOM.parseError <> 0 then  'to catch the error if any
          msgbox "error in line " & objXMLDOM.parseError.Line & " with description '" & objXMLDOM.parseError.reason & "' and text '" & objXMLDOM.parseError.srcText & "'"
end if
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Expert Comment

by:Rejojohny
ID: 10665008
load ur XML file into ur browser .. assuming ur browser is IE ... it too will give u error mesages if there are any errors in ur XML file ...
if u still face a problem and cannot correct it .. post ur XML file and we can have a look into it
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 10668255
Post your text.xml if it is not large
0
 

Author Comment

by:speder
ID: 10668395
Thanks - The problem was a missing DTD file.

I posted a new question that I'm sure will be real easy for you to answer ;-)
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 10668684
any reason for giving just a grade B ?? ur sugestion would help me in my future posts ..
0
 

Author Comment

by:speder
ID: 10671593
Sorry - This was my first attempt in here. I just clicked on Accept - Didn't even see the Grade Option. Can I change it now?
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 10674684
i think so .. u could ask the moderator .. i think .. anyway .. if it is much of a problem for u .. i wouldn't mind if u do not do it ... . I thought u were not happy with the solution and that's y u graded it 'B' ..
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question