speder
asked on
XMLDom not working in standalone vbscript
Hello
I've got an ASP vbscript that works ok. Here it is:
Dim objXMLDOM
Set objXMLDOM = Server.CreateObject("Micro soft.XMLDO M")
objXMLDOM.load(Server.MapP ath("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.XM LDOM")
objXMLDOM.load("c:\test.xm l")
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
I've got an ASP vbscript that works ok. Here it is:
Dim objXMLDOM
Set objXMLDOM = Server.CreateObject("Micro
objXMLDOM.load(Server.MapP
For Each objChild In objXMLDOM.documentElement.
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.XM
objXMLDOM.load("c:\test.xm
For Each objChild In objXMLDOM.documentElement.
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.reaso n & "' and text '" & objXMLDOM.parseError.srcTe xt & "'"
end if
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.reaso
end if
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
if u still face a problem and cannot correct it .. post ur XML file and we can have a look into it
Post your text.xml if it is not large
ASKER
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 ;-)
I posted a new question that I'm sure will be real easy for you to answer ;-)
any reason for giving just a grade B ?? ur sugestion would help me in my future posts ..
ASKER
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?
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' ..
ASKER
Dim objFSO
Set objFSO = CreateObject("Scripting.Fi
Dim objXMLDOM
Set objXMLDOM = CreateObject("Microsoft.XM
objXMLDOM.async = false
objXMLDOM.load("C:/test.xm
if objXMLDOM.parseError <> 0 then 'to catch the error if any
msgbox "Error in loading"
end if
if objFSO.fileExists("C:/test
msgbox "file is there"
end if