小编sso*_*ola的帖子

使用C#解析复杂的XML

我试图用C#解析复杂的XML,我正在使用Linq来做.基本上,我正在向服务器发出请求,我得到XML,这是代码:

XElement xdoc = XElement.Parse(e.Result);
this.newsList.ItemsSource = 
  from item in xdoc.Descendants("item")
  select new ArticlesItem
  {
    //Image = item.Element("image").Element("url").Value,
    Title = item.Element("title").Value,
    Description = this.Strip(item.Element("description").Value).Substring(0, 200).ToString()
  }
Run Code Online (Sandbox Code Playgroud)

这是XML结构:

<item>
  <test:link_id>1282570</test:link_id>
  <test:user>SLAYERTANIC</test:user>
  <title>aaa</title>
  <description>aaa</description>
</item>
Run Code Online (Sandbox Code Playgroud)

我如何访问属性test:link_id例如?

谢谢!

c# xml windows-phone-7

4
推荐指数
1
解决办法
961
查看次数

标签 统计

c# ×1

windows-phone-7 ×1

xml ×1