You do not need to use Using
Just try
Dim StateProv As XmlElement = CType(hotelSearch.SelectSingleNode("/ota:OTA_HotelSearchRQ/ota:Criteria/ota:Criterion/ota:Address/ota:StateProv", nsmgr), XmlElement) 'i am getting error in this line....
StateProv.SetAttribute("StateCode", BLLHotel_Search.StateCode)
StateProv.ChildNodes(0).InnerText = BLLHotel_Search.StateName
From documentation of using
The using keyword :
As a statement,
when it defines a scope at the end of
which an object will be disposed.
To check if it has a value compare it to Nothing
Dim node As XmlNode = doc.SelectSingleNode("//")
If node IsNot Nothing Then
Dim attribute As XmlAttribute = node.Attributes(0)
End If
Try this
Dim StateProv As XmlElement = CType(hotelSearch.SelectSingleNode("/ota:OTA_HotelSearchRQ/ota:Criteria/ota:Criterion/ota:Address/ota:StateProv", nsmgr), XmlElement)
If StateProv IsNot Nothing Then
StateProv.SetAttribute("StateCode", BLLHotel_Search.StateCode)
StateProv.ChildNodes(0).InnerText = BLLHotel_Search.StateName
End If