【发布时间】:2015-05-28 09:07:13
【问题描述】:
我有 customUIXml 类型的 XDocument 对象,它具有以下 XML 作为值:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<ribbon>
<tabs>
<tab id="t1" label="Shalala">
<!-- stuff -->
</tab>
<tab id="tab_dev" label="SomeOtherTab">
<!-- stuff -->
</tab>
<tab id="t108" label="MyTab">
<!-- stuff -->
</tab>
</tabs>
</ribbon>
</customUI>
我想获得标签值为“MyTab”的tab 节点。这是我使用的代码:
Dim xtab As XElement = Nothing
Dim nodes = From nodeToTake In customUIXml.Descendants().Elements("tab") _
Where nodeToTake.Attribute("label").Value = "MyTab"
Select nodeToTake
For Each tab As XElement In nodes
xtab = tab
Next
但我没有得到任何结果,而且我似乎找不到我做错了什么......
【问题讨论】:
标签: vb.net linq-to-xml