0

私のコードは次のようなものです:

        Using 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
    End Using

error:
"using operand of type 'System.xml.xmlelement' must implement 'system.idisposable'"
4

1 に答える 1

1

使用する必要はありません

ちょうど試して

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 

使用のドキュメントから

using キーワード:

ステートメントとして、最後にオブジェクトが破棄されるスコープを定義する場合。

値があるかどうかを確認するには、それと比較しますNothing

Dim node As XmlNode = doc.SelectSingleNode("//")
If node IsNot Nothing Then
    Dim attribute As XmlAttribute = node.Attributes(0)
End If

これを試して

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
于 2009-12-31T07:38:25.307 に答える