我有一个XML
这样的结果
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">16</int>
</lst>
<result name="response" numFound="3" start="0" maxScore="1.0">
<doc>
<str name="ContaFirstname">
firstname1
</str>
<str name="ContaId">6557</str>
<str name="ContaJobTitle">Manager</str>
<str name="ContaSurname">surname1
</str>
</doc>
<doc>
<str name="ContaFirstname">firstname2</str>
<str name="ContaId">6203</str>
<str name="ContaJobTitle">Director</str>
<str name="ContaSurname">surname2</str>
</doc>
</result>
</response>
我想获得对象的列表,每个对象将包含的价值ContaFirstname
, ContaId
, ContaJobTitle
和ContaSurname
我想这样的事情,而是因为我让他们所有NULL那是不对的
var test = from c in xml.Descendants("doc")
select new
{
firstname = c.Element("ContaFirstname"),
surnmane = c.Element("ContaSurname")
};
那么,如何可以访问由名字这些元素?