Учитывая приведенный ниже XML-код, как мне получить список сотрудников, занимающих должности в координатор.coordinator> position_ids?
<employee id="000001">
<username>Bernard</username>
<first_name>BERNARD</first_name>
<last_name>FISHER</last_name>
<business_phone>011111111111</business_phone>
<cell_phone>011111111112</cell_phone>
<hr_contact_name>PETER MANNING</hr_contact_name>
<contract_description>Permanent</contract_description>
<positions>
<position id="00000002" isPrimary="1">
<title>DEVELOPMENT MANAGER</title>
<department id="DV001">DEVELOPMENT</department>
<manager_position>00000002</manager_position>
<coordinators>
<coordinator position_id="00013662"/>
<coordinator position_id="00014488"/>
<coordinator position_id="00022675"/>
<coordinator position_id="00024364"/>
</coordinators>
</position>
</positions>
</employee>
<employee id="000002">
<!-- ... --->
</employee>
Вот что у меня есть:
//GET EMPLOYEE WITH CORORDINATORS AND SUBORINATES WITH POSITION ID
var q = from c in d.Elements().Elements().Elements("positions").Elements("position") where (string)(c.Attribute("id")) == "028782"
select new
{
PositionID = c.Parent.Parent.Attribute("id")
,Username = c.Parent.Parent.Element("username").Value
,FirstName = c.Parent.Parent.Element("first_name").Value
,LastName = c.Parent.Parent.Element("last_name").Value
,ContractDecription = c.Parent.Parent.Element("contract_description").Value
,Title = c.Element("title").Value
,Coordinators = (from coordinator
in d.Elements().Elements().Elements("positions").Elements("position")
join p in c on coordinator.Attribute("id").Value equals p.Attribute("id").Value
select new
{
PositionID = coordinator.Attribute("id")
,Username = coordinator.Parent.Parent.Element("username").Value
,FirstName = coordinator.Parent.Parent.Element("first_name").Value
,LastName = coordinator.Parent.Parent.Element("last_name").Value
,ContractDecription = coordinator.Parent.Parent.Element("contract_description").Value
,thenode = coordinator
})
,thenode = c
};
q.Dump();