天天看點

使用vb.net讀取xml檔案

顯示所有資料。

Dim xn As XmlNode = xmlDoc.SelectSingleNode("bookstore")
Dim xnl As XmlNodeList = xn.ChildNodes
Dim xnf As XmlNode
For Each xnf In xnl
Dim xe As XmlElement = CType(xnf, XmlElement)
Console.WriteLine(xe.GetAttribute("genre")) '顯示屬性值 
Console.WriteLine(xe.GetAttribute("ISBN"))
Dim xnf1 As XmlNodeList = xe.ChildNodes
Dim xn2 As XmlNode
For Each xn2 In xnf1
Console.WriteLine(xn2.InnerText) '顯示子節點點文本 
Next xn2
Next xnf
      

繼續閱讀