相关疑难解决方法(0)

LINQ to XML:应用XPath

有人能告诉我为什么这个程序不会枚举任何项目?它与RDF名称空间有关吗?

using System;
using System.Xml.Linq;
using System.Xml.XPath;

class Program
{
    static void Main(string[] args)
    {
        var doc = XDocument.Load("http://seattle.craigslist.org/sof/index.rss");

        foreach (var item in doc.XPathSelectElements("//item"))
        {
            Console.WriteLine(item.Element("link").Value);
        }

        Console.Read();
    }
}
Run Code Online (Sandbox Code Playgroud)

c# xml linq xpath linq-to-xml

11
推荐指数
1
解决办法
6278
查看次数

标签 统计

c# ×1

linq ×1

linq-to-xml ×1

xml ×1

xpath ×1