嗨我希望将xml文件过滤为属性。
这是我的xml:
<plants>
<plant id="DB" display=".testDB.." group="NPS_DB" />
<plant id="EL" display=".testEL.." group="NPS_EL" />
<plant id="IN" display="..testIN." group="NPS_IN" />
<plant id="SB" display=".testSB.." group="NPS_SB" />
<plant id="BL" display=".testBL.." group="NPS_BL" />
<plant id="LS" display="..testLS.." group="NPS_LS" />
</plants>
这里是我的代码:
ArrayList ActiveUserList = myclass.GetGroupmemberList(Domain, Username);
XDocument x = XDocument.Load(Server.MapPath(@"~\App_Data\location.xml"));
int index = ActiveUserList.Count;
ArrayList DropDownList = new ArrayList();
for (int i = 0; i < index; i++)
{
IEnumerable<XElement> list = from el in x.Descendants("group")
where (string)el.Attribute("Type") == ActiveUserList[i].ToString()
select el;
//Here I want the display attribute value where group = "nps_db" ???
}
例如我的用户名在nps_db组中,所以我希望我得到显示属性,其中是arraylist中的group = np_db。我想稍后将此ArrayList用于DropDownList。