【发布时间】:2015-04-06 18:48:19
【问题描述】:
我有一个包含标识符的 XML 文件,我想将其添加到哈希集字典中以供以后解析。
我对如何使用 linq 从 XML 文件填充此哈希集字典感到困惑。我曾尝试在 stackoverflow 上使用其他帖子,但我的 XML 文件的填充方式与我见过的其他帖子不同。
目前我的 XML 文件如下所示:
<Release_Note_Identifiers>
<Identifier container ="Category1">
<Container_Value>Old</Container_Value>
<Container_Value>New</Container_Value>
</Identifier>
<Identifier container ="Category2">
<Container_Value>General</Container_Value>
<Container_Value>Liquid</Container_Value>
</Identifier>
<Identifier container ="Category3">
<Container_Value>Flow Data</Container_Value>
<Container_Value>Batch Data</Container_Value>
</Identifier>
<Identifier container ="Category4">
<Container_Value>New Feature</Container_Value>
<Container_Value>Enhancement</Container_Value>
</Identifier>
</Release_Note_Identifiers>
我想将所有这些添加到Dictionary<string, HashSet<string>>(),其中键是每个类别,哈希集包含每个容器值。
我想让它尽可能抽象,因为我想最终添加更多类别并为每个类别添加更多容器值。
谢谢!
【问题讨论】:
标签: c# xml linq dictionary linq-to-xml