C# & Xml Nodes - Help!

I have a problem. I want to retrieve all the title attributes from the [array key] node

You can view the XML here http://api.ustream.tv/xml/user/socaldavis/...7fescmekvx35f3q

The method I have below is only returning on value. When I know there are three! Can anyone help me with this? I am not all that good with XPath Syntext.

public string GetChannelList()
{
XmlDocument xdoc = new XmlDocument();
xdoc.Load("http://api.ustream.tv/xml/user/socaldavis/listAllChannels?key=kdbkes7hh7fescmekvx35f3q");

XmlElement root = xdoc.DocumentElement;
//I do this because using "array key=*" throws an invalid token error
XmlNodeList nodes = root.SelectNodes("//xml//results//node()");

foreach (XmlNode theNode in nodes)
{
string data = theNode["title"].InnerText;
frmMain.lstResults.Items.Add(data);

return data;
}
return null;
}

#527820

I'm not sure, but... try commenting out return data; and see if then correctly fills lstResults with all three results.

#527821

Looking at the xml returned from the URL you mentioned, it seems to me that you should look for array elements by using an XPath expression like root.SelectNodes("//xml//results//array//node()");

Since results elements are only one, but there are three array elements.

Hope I read your question properly.

#527823

You both helped me on this :) I commented out the return and I used "//xml//restuls//array" and now I get all the results. So simple. Thank a ton guys.

#527827

Don't mention it... I'm glad we could help you out.

#527857