问一linq to xml问题

jxdom 2010-12-24 08:48:30
我的xml如下:

<feed gd:kind="buzz#activityFeed" xmlns="http://www.w3.org/2005/Atom" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:buzz="http://schemas.google.com/buzz/2010" xmlns:crosspost="http://purl.org/syndication/cross-posting" xmlns:gd="http://schemas.google.com/g/2005" xmlns:georss="http://www.georss.org/georss" xmlns:media="http://search.yahoo.com/mrss/" xmlns:poco="http://portablecontacts.net/ns/1.0" xmlns:thr="http://purl.org/syndication/thread/1.0">
<link rel="self" type="application/atom+xml" href="https://www.googleapis.com/buzz/v1/activities/103854838474576564357/@public?alt=atom" />
<link rel="hub" href="http://pubsubhubbub.appspot.com/" />
<title>Google Buzz Public Feed for ddddddd</title>
<updated>2010-12-21T13:44:03.083Z</updated>
<id>tag:google.com,2010:buzz-feed:public:posted:103854838474576564357</id>
<generator uri="http://www.google.com/buzz">Google Buzz</generator>
<entry gd:kind="buzz#activity">
<title>asdfasdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdf。</title>
<published>2010-12-21T13:44:02.000Z</published>
<updated>2010-12-21T13:44:03.083Z</updated>
<id>tag:google.com,2010:buzz:z125iffjxznzj5pkk23dzhupbwvhzxdep</id>
<link rel="alternate" type="text/html" href="http://www.google.com/buzz/103854838474576564357/3nokvYxiAdf" />
<link rel="self" type="application/atom+xml" href="https://www.googleapis.com/buzz/v1/activities/103854838474576564357/@self/B:z125iffjxznzj5pkk23dzhupbwvhzxdep?alt=atom" />
<link rel="replies" type="application/atom+xml" href="https://www.googleapis.com/buzz/v1/activities/103854838474576564357/@self/B:z125iffjxznzj5pkk23dzhupbwvhzxdep/@comments?alt=atom" thr:count="0" thr:updated="2010-12-21T13:44:03.083Z" />
<author>
<poco:id>103854838474576564357</poco:id>
<poco:photoUrl />
<name>ddddddd</name>
<uri>http://www.google.com/profiles/103854838474576564357</uri>
<link rel="photo" type="image/jpeg" href="" />
<activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
</author>
<content type="html">asdfasdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdf。</content>
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
<activity:object>
<activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
<content type="html">asdfasdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdf。</content>
<buzz:original-content type="text" />
<link rel="alternate" type="text/html" href="http://www.google.com/buzz/103854838474576564357/3nokvYxiAdf" />
</activity:object>
<source>
<activity:service>
<title>www.asdd.com</title>
</activity:service>
</source>
<buzz:visibility>
<buzz:aclentry type="group">
<poco:id>G:@me:@public</poco:id>
<uri>https://www.googleapis.com/buzz/v1/people/@me/@groups/G:@me:@public?alt=atom</uri>
<poco:name>Public</poco:name>
</buzz:aclentry>
</buzz:visibility>
<link rel="http://schemas.google.com/buzz/2010#liked" type="application/poco+xml" href="https://www.googleapis.com/buzz/v1/activities/103854838474576564357/@self/B:z125iffjxznzj5pkk23dzhupbwvhzxdep/@liked?alt=atom" buzz:count="0" />
</entry>
</feed>



var queryda = from entry in xelement.Elements(XName.Get("entry", "http://www.w3.org/2005/Atom"))
select new
{
stsource = entry.Element(XName.Get("source", "http://www.w3.org/2005/Atom")).Element(XName.Get("service", "http://activitystrea.ms/spec/1.0/")).Element(XName.Get("title", "http://www.w3.org/2005/Atom")).Value,
             linkcount = entry.Element(XName.Get("link", "http://www.w3.org/2005/Atom")).Attribute("http://schemas.google.com/buzz/2010" + "count").Value,//这里出错
};

问题1我想取得
<link rel="http://schemas.google.com/buzz/2010#liked" type="application/poco+xml" href="https://www.googleapis.com/buzz/v1/activities/103854838474576564357/@self/B:z125iffjxznzj5pkk23dzhupbwvhzxdep/@liked?alt=atom" buzz:count="0" />中的count值。

还有一个问题就是,entry.Element(XName.Get("link" 得到几个link,我以上语句如何区分想要的link?是通过rel条件吗?如果是,这个条件怎么判断?
...全文
68 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
jxdom 2010-12-25
  • 打赏
  • 举报
回复
没人回答?急。。

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧