【发布时间】:2013-02-05 12:38:18
【问题描述】:
<Default>
<SharepointContentType id="SharePointContentType">
<name id="Test1"
DisplayName="TestOne"
SharepointGroup="Test1SPGp">
</name>
<name id="Test2"
DisplayName="TestTwo"
SharepointGroup="Test2SPGp">
</name>
.
.
.
.
</SharepointContentType>
.
.
.
.
<Default>
对于我想要下降的上述模式,找到一个节点,其中 id 是 SharePointContentType,而不是找到标签 <name >,其中 id 是 Test1(用户定义),然后获取元素 SharepointGroup 的值
例如,如果用户输入是 Test1 而输出应该是 Test1SPGp 请帮助我尝试使用 linq 并设法编写如下代码,但未能成功。
XDocument xDoc = XDocument.Load(GetDefaultXMLFile());
var feeds = from feed in xDoc.Descendants("name")
where feed.Attribute("id").Equals("admin")
select new
{
fxfv = feed.Attribute("SharepointGroup").Value
};
【问题讨论】:
标签: xml linq c#-4.0 linq-to-xml readxml