こんにちは、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 のグループ = np_db である表示属性を取得したいと考えています。この ArrayList を後で DropDownList に使用したいと考えています。