Retrieve single attribute value from an xml doc element

前端 未结 1 1090
一整个雨季
一整个雨季 2020-12-22 05:52

I have an xml document with the following structure



  

        
相关标签:
1条回答
  • 2020-12-22 06:22

    This is a little older-school, but it works and is very readable/maintainable...

    Public Function GetContinents() As List(Of String)
        Dim doc As New XmlDocument
        doc.Load("c:\yourfile.xml")
        Dim ReturnValue As New List(Of String)
        For Each node As XmlNode In doc.SelectNodes("//Continent")
            ReturnValue.Add(node.Attributes("name").Value)
        Next
        Return ReturnValue
    End Function
    
    0 讨论(0)
提交回复
热议问题