【发布时间】:2015-08-08 14:52:22
【问题描述】:
我有简单的 XML。我想在 VB.NET WindowsForm 应用程序中选择 CASE where Section = "A" by LINQ。我将不胜感激任何帮助。提示可以在 C# 中。谢谢。
<?xml version="1.0" encoding="UTF-8"?>
<data>
<PredefinedText>
<Section>A</Section>
<CASE>Case 1A</CASE>
</PredefinedText>
<PredefinedText>
<Section>B</Section>
<CASE>Case 1B</CASE>
</PredefinedText>
</data>
我有这段代码,但它不会向 ComboBox 返回任何记录...
sSettingsFilePath = "Sections.xml"
Dim xelement As XElement = xelement.Load(sSettingsFilePath)
ComboBox1.DataSource = (From cases In xelement.Elements("PredefinedText") _
Select cases.Element("CASE").Value _
Where xelement.Element("PredefinedText").Element("Section").Value = "A"
Order By Value).ToList()
【问题讨论】:
-
你有什么问题?
-
你的 xml 查询返回你想要的。
-
嗨,Maciej 和琼斯。谢谢您的答复。查询结果是我得到了所有部分的所有案例,不限于“A”部分。我只想得到“案例 1A”。