如何使用此类方法在此xml中填充值dept [英] how to populate the value dept in this xml using this class method
本文介绍了如何使用此类方法在此xml中填充值dept的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用此xml和此方法,我想将dept的值加载到page_load()label.text
I'm using this xml and this method, i want to load the value of dept to page_load() label.text
<?xml version="1.0"?>
<information>
<details>
<id>01</id>
<empname>qwer</empname>
<empid>001</empid>
<dept>Accounts</dept>
<date>2011-01-15 12:21:25</date>
</details>
<details>
<id>02</id>
<empname>jdfklgd</empname>
<empid>002</empid>
<dept>Finance</dept>
<date>2011-01-20 10:21:25</date>
</details>
</information>
这是我的.cs
public void getnodes(string id)
{
var xmlStr = File.ReadAllText(@"C:\Users\Gabriel\Emp.xml");
var str = XElement.Parse(xmlStr);
var result = str.Elements("details").
Where(x => x.Element("id").Value.Equals(id)).ToList();
}
推荐答案
为了获得第一个和第二个部门,请尝试以下操作:
In order to get the first and the second departments, try this:
然后您可以在标签中显示名称.
Then you can display the names in labels. 可以根据您的特定需求查找或提取更多信息. It is possible to find or extract more information according to your specific needs. 这篇关于如何使用此类方法在此xml中填充值dept的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文