C# 使用Xpath提取属性
我需要从XML文件中提取属性,然后将它们添加到listview中 如何使用Xpath(winforms)提取属性: e、 g:C# 使用Xpath提取属性,c#,winforms,xpath,C#,Winforms,Xpath,我需要从XML文件中提取属性,然后将它们添加到listview中 如何使用Xpath(winforms)提取属性: e、 g: meh 例如,如何提取“foo”和“lol”中的数据?(因此“1”和“3”) 当然,如果您想从c#应用程序中获取此类节点,您需要执行以下操作: XmlDocument o = new XmlDocument(); o.Load(@"c:\file.xml"); var attribute1 = o.SelectSingleNode(&q
meh
例如,如何提取“foo”和“lol”中的数据?(因此“1”和“3”)
当然,如果您想从c#应用程序中获取此类节点,您需要执行以下操作:
XmlDocument o = new XmlDocument();
o.Load(@"c:\file.xml");
var attribute1 = o.SelectSingleNode("/element/@foo");
在这种情况下,不要忘了添加using语句“using System.Xml”,以防还没有。请记住,要相信有用的答案!;)
/element/@foo
/element/@lol
XmlDocument o = new XmlDocument();
o.Load(@"c:\file.xml");
var attribute1 = o.SelectSingleNode("/element/@foo");