C# 在.net中的Twitter API消费中获取空指针异常
我正在开发一个基于.net的应用程序来使用Twitter API。我收到以下错误: System.NullReferenceException:对象 引用未设置为的实例 反对 代码如下C# 在.net中的Twitter API消费中获取空指针异常,c#,twitter,C#,Twitter,我正在开发一个基于.net的应用程序来使用Twitter API。我收到以下错误: System.NullReferenceException:对象 引用未设置为的实例 反对 代码如下 StringBuilder strB = new StringBuilder(); XmlReader reader = new XmlTextReader("http://twitter.com/statuses/public_timeline.xml"); try { while (reader.Re
StringBuilder strB = new StringBuilder();
XmlReader reader = new XmlTextReader("http://twitter.com/statuses/public_timeline.xml");
try
{
while (reader.ReadToFollowing("user"))
{
strB.Append("z: " + reader.GetAttribute("id").ToString());
strB.Append(" | Y: " + reader.GetAttribute("name").ToString());
strB.Append(" | style: " + reader.GetAttribute("style").ToString());
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
finally
{
reader.Close();
}
Response.Write(strB.ToString());
有人能帮我吗
提前谢谢
Daman您是否考虑过使用第三方客户端库 这里有一些免费的选择
名称
、id
和样式
是标记,而不是属性。因此,
GetAttribute
返回nullname
,id
和style
是标记,而不是属性。
因此,GetAttribute
返回null
您忘记发布代码。您从哪里获得NullReferenceException?请验证您的阅读器是否能够获得id、名称和样式。将调用reader.GetAttribute(“xxx”)
的结果放入一个变量中,并查看其内容。您忘记发布代码。从何处获取NullReferenceException?请验证您的读取器是否能够获取id、名称和样式。将调用reader.GetAttribute(“xxx”)
的结果放入变量中,查看内容。是否有可用的免费工具?是否有可用的免费工具?