我正在尝试解析以下 Xml。它可能有多个发票标签:
<Invoices>
<Invoice>
<Invoice_ID>1234</Invoice_Id>
<Billing>
<Name> abc </Name>
<Address1>1 main street</Address1>
<City> city </city>
<State>State </State
<Zip>00000</zip>
<Amount>
<BaseAmt>35</BaseAmt>
<Tax>3</Tax>
<Total>28<total>
<Amount>
</Billing>
<item>
<Name> pen </Name>
<qty> 5 </qty>
<amount> 10 </amount>
</item>
<item>
<Name> Paper </Name>
<qty> 3 </qty>
<amount> 20 </amount>
</item>
</Invoice>
</Invoices>
下面是我的代码:
Dim xmlDoc As XmlDocument = New XmlDocument()
xmlDoc.Load(fileName)
Dim invNum As Integer = 0
Dim nodeLst As XmlNodeList = xmlDoc.SelectNodes("/Invoices/Invoice")
invNum = nodeLst.Count
For Each invDetail As XmlElement In nodeLst
Dim invID As String = invDetail("Invoice_ID").InnerText.ToString()
Next
我需要获取剩余标签的值,即子节点,例如 Billing/Name 、 Billing/Name/Amount 、 Items/Items/Name