How can query below document so it would give me value of "id" (the one in the root after status) ?
this gives an error (Object reference not set to an instance of an object.)
using (WebResponse response = request.GetResponse())
{
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
string responseString = reader.ReadToEnd();
XDocument document = XDocument.Parse(responseString, LoadOptions.None);
return (from e in document.Root.Elements("status")
select e.Element("id").Element("name").Value).SingleOrDefault().ToString();
return responseString;
}
}
XML
<?xml version="1.0" encoding="UTF-8"?>
<status>
<created_at>Tue Sep 29 09:33:23 +0000 2009</created_at>
<id>xxxxxxxxxxxxxx</id>
<text>test</text>
<source><a href="http://apiwiki.twitter.com/" rel="nofollow">API</a></source>
<truncated>false</truncated>
<in_reply_to_status_id></in_reply_to_status_id>
<in_reply_to_user_id></in_reply_to_user_id>
<favorited>false</favorited>
<in_reply_to_screen_name></in_reply_to_screen_name>
<user>
<id>xxxx</id>
<name>xxx</name>
<screen_name>xxx</screen_name>
</user>
</status>