且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在组合框中从XML获取值?

更新时间:2023-11-14 09:29:10

应该是:



Should be:

For Each node As XmlNode In nodes
      Dim name = node["NAME"].InnerText
      cbxList.Items.Add(Name)
Next


尝试下面的代码片段,它将解决您的问题 -





Try with below code snippet it will resolve your issue -


Dim RA_File As String = "E:\XMLFile1.xml"
ComboBox1.Items.Clear()
Dim xmlDoc As XDocument = XDocument.Load(RA_File)
Try
    For Each node As XElement In xmlDoc.Root.Descendants("RISKITEM")
        ComboBox1.Items.Add(node.Attribute("NAME").Value)
    Next
Catch ex As Exception
    MsgBox(ex.Message)
End Try