dbTalk Databases Forums  

Check for XML Node existance in DTS

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Check for XML Node existance in DTS in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Stacey Levine
 
Posts: n/a

Default Check for XML Node existance in DTS - 02-05-2004 , 10:17 AM






I have a script (thanks to Darren) that is working to import an XML file
into a database. Unfortunately, sometimes a node does not exist at all. I
tried using IsObject .. and IsNull
but I still get the same error. Any ideas would be greatly appreciated

IF IsObject(
objTitleNode.selectSingleNode("title-info/genre").nodeTypedValue ) Then
sGenre =
Left(objTitleNode.selectSingleNode("title-info/genre").nodeTypedValue,25)
Else
sGenre = ""
End If



Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Check for XML Node existance in DTS - 02-05-2004 , 11:28 AM






You cannot read a property from an object that is nothing, so you must first
check if the selectSingleNode actually returned anything-

Set oNode = objTitleNode.selectSingleNode("product-info/upcXX")
If Not oNode Is Nothing Then sUPC = oNode.nodeTypedValue

--
Darren Green
http://www.sqldts.com


"Stacey Levine" <staceyl (AT) SMAPFILTERmusicforasong (DOT) com> wrote

Quote:
I have a script (thanks to Darren) that is working to import an XML file
into a database. Unfortunately, sometimes a node does not exist at all. I
tried using IsObject .. and IsNull
but I still get the same error. Any ideas would be greatly appreciated

IF IsObject(
objTitleNode.selectSingleNode("title-info/genre").nodeTypedValue ) Then
sGenre =
Left(objTitleNode.selectSingleNode("title-info/genre").nodeTypedValue,25)
Else
sGenre = ""
End If





Reply With Quote
  #3  
Old   
Stacey Levine
 
Posts: n/a

Default Re: Check for XML Node existance in DTS - 02-05-2004 , 01:26 PM



Thanks.. I will give that a shot..
"Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote

Quote:
You cannot read a property from an object that is nothing, so you must
first
check if the selectSingleNode actually returned anything-

Set oNode = objTitleNode.selectSingleNode("product-info/upcXX")
If Not oNode Is Nothing Then sUPC = oNode.nodeTypedValue

--
Darren Green
http://www.sqldts.com


"Stacey Levine" <staceyl (AT) SMAPFILTERmusicforasong (DOT) com> wrote in message
news:%23MELSOA7DHA.712 (AT) tk2msftngp13 (DOT) phx.gbl...
I have a script (thanks to Darren) that is working to import an XML file
into a database. Unfortunately, sometimes a node does not exist at all.
I
tried using IsObject .. and IsNull
but I still get the same error. Any ideas would be greatly appreciated

IF IsObject(
objTitleNode.selectSingleNode("title-info/genre").nodeTypedValue ) Then
sGenre =

Left(objTitleNode.selectSingleNode("title-info/genre").nodeTypedValue,25)
Else
sGenre = ""
End If







Reply With Quote
  #4  
Old   
Stacey Levine
 
Posts: n/a

Default Re: Check for XML Node existance in DTS - 02-05-2004 , 09:04 PM



That definately did it. Thanks alot

Stacey
Quote:
-----Original Message-----
You cannot read a property from an object that is
nothing, so you must first
check if the selectSingleNode actually returned anything-

Set oNode = objTitleNode.selectSingleNode("product-
info/upcXX")
If Not oNode Is Nothing Then sUPC = oNode.nodeTypedValue

--
Darren Green
http://www.sqldts.com


"Stacey Levine" <staceyl (AT) SMAPFILTERmusicforasong (DOT) com
wrote in message
news:%23MELSOA7DHA.712 (AT) tk2msftngp13 (DOT) phx.gbl...
I have a script (thanks to Darren) that is working to
import an XML file
into a database. Unfortunately, sometimes a node does
not exist at all. I
tried using IsObject .. and IsNull
but I still get the same error. Any ideas would be
greatly appreciated

IF IsObject(
objTitleNode.selectSingleNode("title-
info/genre").nodeTypedValue ) Then
sGenre =
Left(objTitleNode.selectSingleNode("title-
info/genre").nodeTypedValue,25)
Else
sGenre = ""
End If




.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.