detecting "object required" or null object 
Author Message
 detecting "object required" or null object

Hi,

I'm using the XML DOM from VBScript and I want to detect whether
selectSingleNode()
has returned an object or not. e.g. the following code works fine but how
do I know if "nodeobj" is a valid object ? If you change the pattern search
to "test/xxx"
then MsgBox line fails with "object required".

Thanks

set obj = CreateObject("MSXML.DOMDocument")
obj.loadXML("<test><hello>bye</hello></test>")
set nodeobj = obj.selectSingleNode("test/hello")        // change search
pattern to "test/xxxx" to get error
MsgBox nodeobj.text
set nodeobj = nothing
set obj = nothing



Mon, 07 Jul 2003 03:40:24 GMT  
 detecting "object required" or null object
set obj = CreateObject("MSXML.DOMDocument")
obj.loadXML("<test><hello>bye</hello></test>")
set nodeobj = obj.selectSingleNode("test/hello")      
if not (nodeobj Is Nothing) then
  msgbox "1) it worked..."
else
  msgbox "1) it didn't..."
end if
set nodeobj = obj.selectSingleNode("test/xxxx")      
if not (nodeobj Is Nothing) then
  msgbox "2) it worked..."
else
  msgbox "2) it didn't..."
end if

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> Hi,

> I'm using the XML DOM from vbscript and I want to detect whether
> selectSingleNode()
> has returned an object or not. e.g. the following code works fine but how
> do I know if "nodeobj" is a valid object ? If you change the pattern search
> to "test/xxx"
> then MsgBox line fails with "object required".

> Thanks

> set obj = CreateObject("MSXML.DOMDocument")
> obj.loadXML("<test><hello>bye</hello></test>")
> set nodeobj = obj.selectSingleNode("test/hello")        // change search
> pattern to "test/xxxx" to get error
> MsgBox nodeobj.text
> set nodeobj = nothing
> set obj = nothing



Mon, 07 Jul 2003 10:53:41 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. "multitasking" in bp7/dpmi.. + dlls, pmode, etc.

2. Pascal Question

3. detecting "object required" or null object

4. Detecting "null"-object

5. Anyone have a pascal program similar to this?

6. how to return a "null" object

7. "...Is null or not an object"

8. "Object Required" error

9. help: error 424 "Object Required"

10. "Object Required" in Visual Basic

11. Help: "Object Required" - error 424

12. "Object Required" for recordset

 

 
Powered by phpBB® Forum Software