OK, I have this code for parsing an incoming XML post.
However, those values are not always included. For instance, I may not get Phone1. I know that my code right now will return an error, but am I missing something whereby I could easily set a default value if that field is not included in the XML doc? I know there is an IsNull function in VBScript so I could do an
statement, just wondering if there is something else that I could do.
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 city : city = Trim(cStr("" & myDoc.getElementsByTagName("cbt:LicenseeContact/cbt:City").item(0).text))
Dim StateCode : StateCode = Trim(cStr("" & myDoc.getElementsByTagName("cbt:LicenseeContact/cbt:StateId").item(0).text))
Dim postalcode : postalcode = Trim(cStr("" & myDoc.getElementsByTagName("cbt:LicenseeContact/cbt:PostalCode").item(0).text))
Dim countrycode : countrycode = Trim(cStr("" & myDoc.getElementsByTagName("cbt:LicenseeContact/cbt:CountryId").item(0).text))
Dim phone : phone = Trim(cStr("" & myDoc.getElementsByTagName("cbt:LicenseeContact/cbt:Phone1").item(0).text))
Dim lang : lang = Trim(cStr("" & myDoc.getElementsByTagName("cbt:LicenseeContact/cbt:Language").item(0).text))
However, those values are not always included. For instance, I may not get Phone1. I know that my code right now will return an error, but am I missing something whereby I could easily set a default value if that field is not included in the XML doc? I know there is an IsNull function in VBScript so I could do an
Code:
IF IsNull(expression) THEN variable='some preset value'
Thanks,
Willie