I have cut and paste this example from http://devguru.org/Technologies/xmldom/quickref/node_selectSingleNode.html
and I can’t get it to work.
I keep getting object errors like this:
Microsoft VBScript runtime (0x800A01A8)
Object required
This is the code and xml file I am using
<%
option explicit
Dim objXMLDoc
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load(Server.MapPath("vocabulary.xml"))
Dim Node
Set Node = objXMLDoc.documentElement.selectSingleNode("label")
Response.write Node.text
%>
xml file
<?xml version="1.0" encoding="utf-8" ?>
<labels>
<label>Some label</label>
</labels>
The error mentioned is probably at the level of the last line. Assuming all other calls to the XMLDOM object worked smoothly, selectSingleNode would return null, since “label” as a path would not be found.
Try with
instead. Alternatively, and this is a good practice with this type of DOM logic, you could test for successful return from selectSingleNode