Hi there!
I am busy creating a desktop application with Windows.Forms to display Twitter XML data inside a textbox on a form.
The XML structure looks like this:
<statusses>
<status>
<text>...</text>
<user>
<name>...</name>
</user>
</status>
<status>
<text>...</text>
<user>
<name>...</name>
</user>
</status>
</statusses>
The problem is that with my code I can get anything inside the "status" subcategory but not ALSO inside the "user" subcategory (within it). So I have two separate calls to the different subcategories.
Now I would like to know how can I join the two so that I can display a username and tweet with a foreach loop? Because if I use two foreach loops the first displays all usernames and then the second all tweets. I would like to display username+tweet, username+tweet.
XDocument feedXML = XDocument.Load("http://twitter.com/statuses/public_timeline.xml");
var feeds = from feed in feedXML.Descendants("status")
select new
{
Tweet = feed.Element("text"),
};
var feedz = from feed in feedXML.Descendants("user")
select new
{
User = feed.Element("screen_name"),
};
// This does not work
var query = feedz.Concat(feeds);
foreach (var group in query)
{
textUpdates.AppendText(group.User.Value.ToString() + "\r\n" + group.Tweet.Value.ToString());
}
Otherwise this works but it displays username+username+username followed by tweet+tweet+tweet
XDocument feedXML = XDocument.Load("http://twitter.com/statuses/public_timeline.xml");
var feeds = from feed in feedXML.Descendants("status")
select new
{
Tweet = feed.Element("text"),
};
var feedz = from feed in feedXML.Descendants("user")
select new
{
User = feed.Element("screen_name"),
};
foreach (var feed in feeds)
{
textUpdates.AppendText(feed.Tweet.Value.ToString() + "\r\n");
}
foreach (var fed in feedz)
{
textUpdates.AppendText(fed.User.Value.ToString() + "\r\n");
}
Any solution? :P