【发布时间】:2013-11-11 10:21:32
【问题描述】:
XML:
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007">
...
<author>
<name>Seamless</name>
<uri>https://gdata.youtube.com/feeds/api/users/SeamlessR</uri>
</author>
代码:
var ns = XNamespace.Get("http://www.w3.org/2005/Atom");
var name = xDoc.Descendants(ns + "entry").First().Element("author").Element("name").Value;
上面写着Object reference not set to an instance of an object.
【问题讨论】:
-
你有没有通过调试器看看
NULL到底是什么? -
@O.R.Mapper:不,它将使用
XName +(XNamespace, string)运算符。
标签: c# .net xml parsing xml-parsing