So, I receive this post from an outside vendor and there are a few elements that may or may not be present. What I am trying to figure out is how I can handle those elements that may or may not be there. I had thought I could use ISNULL, but I cannot get it to work. The code below:
works fine with just Street1, but once I add Phone1 (and don't include it in the XML being passed) I get the error
Anybody out there run into this problem before or know how I should handle it? When this field is available I need it, otherwise I will just set it to 0, but it isn't working for me!
Thanks,
Willie
Code:
Dim myDoc
set myDoc = Server.CreateObject("Microsoft.XMLDOM")
myDoc.async=false
myDoc.loadXML(request.Form("xml"))
Dim Root
Set Root = MyDoc.documentElement
Dim street : street = Trim(cStr("" & myDoc.getElementsByTagName("cbt:LicenseeContact/cbt:Street1").item(0).text))
Dim phone : IF ISNULL(myDoc.getElementsByTagName("cbt:LicenseeContact/cbt:Phone1").item(0).text) then phone="" ELSE phone = Trim(cStr("" & myDoc.getElementsByTagName("cbt:LicenseeContact/cbt:Phone1").item(0).text)) END IF
Code:
Object required: 'getElementsByTagName(...).item(...)'
Anybody out there run into this problem before or know how I should handle it? When this field is available I need it, otherwise I will just set it to 0, but it isn't working for me!
Thanks,
Willie