获取特定的Xml节点
如何从此提要中获取“入口”节点
http://www.google.com/alerts/feeds/14392773026536511983/5526937985735563 348< /a>
我尝试了 linq to xml 但我认为由于条目标记的现有属性,以下代码不起作用。
string url = "http://www.google.com/alerts/feeds/14392773026536511983/5526937985735563348";
WebClient c = new WebClient();
string xml = ASCIIEncoding.Default.GetString(c.DownloadData(url));
XDocument doc = XDocument.Parse(xml);
var entries = doc.Descendants("entry");
提前致谢,
How can I get "entry" nodes from this feed
http://www.google.com/alerts/feeds/14392773026536511983/5526937985735563348
I tried linq to xml but I think because of the existing attributes of entry tags following code does not work.
string url = "http://www.google.com/alerts/feeds/14392773026536511983/5526937985735563348";
WebClient c = new WebClient();
string xml = ASCIIEncoding.Default.GetString(c.DownloadData(url));
XDocument doc = XDocument.Parse(xml);
var entries = doc.Descendants("entry");
Thanks in advance,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您没有指定名称空间。试试这个:
顺便说一句,我不会为此使用 ASCII,或者
DownloadData
... 使用WebClient.DownloadString
来为您处理编码。或者实际上,只需使用 XDocument.Load(url):例如:
You're not specifying a namespace. Try this:
Btw, I wouldn't use ASCII for this, or
DownloadData
... useWebClient.DownloadString
to handle the encoding for you. Or indeed, just useXDocument.Load(url)
:For example:
这些数据以 Atom 格式呈现,因此您需要根据标准规范对其进行解析。最简单的方法是查看开源代码。查看此链接,您需要“为 Atom 创建通用解析器” 、RDF 和 RSS feed”部分
This data presented in Atom format, so you need to parse it according to the standard specification. The simplest way is take a look on to open source code. Check out This link, you are need "Creating a generic parser for Atom, RDF and RSS feeds" part