Jump to content

C# & Xml Nodes - Help!


Recommended Posts

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;
}

Link to post

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.

Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...