Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要从 XML 文件中提取属性,然后将它们添加到列表视图中。
如何使用 Xpath (winforms) 提取属性:
例如:
<element foo="1" meh="2" lol="3" hi="4">meh</element>
例如,如何提取“foo”和“lol”中的数据?(所以“1”和“3”)
/element/@foo /element/@lol
当然,如果您想从 ac# 应用程序中获取此类节点,则需要执行以下操作:
XmlDocument o = new XmlDocument(); o.Load(@"c:\file.xml"); var attribute1 = o.SelectSingleNode("/element/@foo");