Altova Mailing List Archives

Re: XMLDOM / Conditional Check for Object fails

From: "Mark Schupp" <notvalid@-----.--->
Date: 5/31/2005 12:23:00 PM
try this:

If Not IsDomTextNode( oItemPrice) Then

'check if selectSingleNode returned a valid text node
Function IsDomTextNode( ByRef objNode )

     Dim strTmp

     On Error Resume Next
     strTmp = objNode.text

     If Err.Number = 0 Then
          IsDomTextNode = True
          IsDomTextNode = False
     End If

End Function

You should also be able to use the nodeType property of the node to see if 
it is the type you expect. I can't remember why I used to above approach.

--Mark Schupp

"joe" <nobody@n...> wrote in message 
>I am having problems checking for the value of an XMLDOM object .
> Lets say my XMLDOM object was successfully created as objXMLDoc, and that
> has several nodes on it. In the case of a VBScript loop like below:
> '-------------------
> For x = 1 To 10
>  Set oItemPrice = objXMLDoc.selectSingleNode("//Item[x]/Price")
>  '--- conditional stuff that fails here
> Next
> '-------------------
> some of the Items don't have a price, therefore the object oItemPrice will
> fail at some point. So I want to check for this failure, but everything I 
> do
> gives me errors.
> Examples:
> 1.  If not oItemPrice Then
> 2.  If oItemPrice.lenght = 0 Then
> 3.  If oItemPrice = empty or oItemPrice = "" or isnull(oItemPrice) Then
> 4.  If not (oItemPrice) Then
> I really don't know what to do. Most errors are like:
> " Object doesn't support this property or method"
> Any help is appreciated.


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.