djwilliams Posted May 16, 2009 Report Share Posted May 16, 2009 I have a problem. I want to retrieve all the title attributes from the [array key] nodeYou can view the XML here http://api.ustream.tv/xml/user/socaldavis/...7fescmekvx35f3qThe 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 comment
matonga Posted May 16, 2009 Report Share Posted May 16, 2009 I'm not sure, but... try commenting out return data; and see if then correctly fills lstResults with all three results. Link to comment
Smaky Posted May 17, 2009 Report Share Posted May 17, 2009 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 comment
djwilliams Posted May 17, 2009 Author Report Share Posted May 17, 2009 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. Link to comment
Smaky Posted May 17, 2009 Report Share Posted May 17, 2009 Don't mention it... I'm glad we could help you out. Link to comment
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now