Image I have this XML:
<ipb>
<profile>
<id>335389</id>
<name>stapia.gutierrez</name>
<rating>0</rating>
</profile>
</ipb>
I'm trying to get ID, Name and Rating. Any guidance?
Here's what I have and what I receive:
public User FindInformation()
{
string xml = new WebClient().DownloadString(String.Format("http://www.dreamincode.net/forums/xml.php?showuser={0}", userID));
XDocument doc = XDocument.Parse(xml);
var id = from u in doc.Descendants("profile")
select (string)u.Element("id");
var name = from u in doc.Descendants("profile")
select (string)u.Element("name");
var rating = from u in doc.Descendants("profile")
select (string)u.Element("rating");
User user = new User();
user.ID = id.ToString();
user.Name = name.ToString();
user.Rating = rating.ToString();
return user;
}
This is what I get in my TextBox for testing purposes.
System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String] System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String] System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String]