我有一个 xml 文件,例如:
<config>
<email Host="201.0.0.0" From="mail@mail.com" Pass="xxx" Name="xxx"/>
<gir g1="Traditional" g2="mid Techn" g3="High Tech"/>
<costs>
<Pre-Incube inscr="7000.00" add="300.00"/>
<Normal inscr="1600.00" inc="7000.00" add="500.00"/>
<Urgent inscr="1600.00" inc="5000.00" add="500.00"/>
<Estance inscr="1600.00" men="2500.00"/>
<Post inscr="1600.00" men="1500.00"/>
</costs>
</config>
要获取元素“gir”的属性,我会这样做
Dim doc As XmlDocument = New XmlDocument()
doc.Load(path)
Dim root As XmlNode = doc.DocumentElement
Dim nodeGir As XmlNode = root.SelectSingleNode("/config/gir")
cboGir.Items.Add(nodeGir.Attributes.ItemOf("g1").InnerText)
cboGir.Items.Add(nodeGir.Attributes.ItemOf("g2").InnerText)
cboGir.Items.Add(nodeGir.Attributes.ItemOf("g3").InnerText)
但是如何获取“成本”下的子元素的名称:
Pre-Incube, Normal, Urgent, Estance, Post