【发布时间】:2012-07-11 11:52:06
【问题描述】:
我在下面有一部分应用程序初始化字符串:
<Controls>
<HtmlElement name="lnkLogIn" type="HtmlElement">
<AttributeMatchPath matchtype="equals">
<href>JavaScript:void(0)</href>
<id>s_swepi_22</id>
</AttributeMatchPath>
</HtmlElement>
<InputElement name="tbPassword" type="InputElement">
<AttributeMatchPath matchtype="equals">
<id>s_swepi_2</id>
</AttributeMatchPath>
</InputElement>
<InputElement name="tbUserID" type="InputElement">
<AttributeMatchPath matchtype="equals">
<id>s_swepi_1</id>
</AttributeMatchPath>
</InputElement>
</Controls>
我想要在后面的代码中做的是一个函数,它获取每个控件的 Inputelement name 和 id 作为键值对,并返回一个字典对象或类似的东西,我们可以从中提取键值对信息。
这基本上是为了删除 ID 值的硬编码......所以从初始化字符串中获取元素名和 id 并将它们存储为键值对的通用解决方案将非常棒......提前致谢:)
PS:使用 C#.....
【问题讨论】:
标签: c# .net dictionary initialization