ASP.NET reads external XML from the website

I want to read an XML file located here

The data looks like this

< profile> 
76561197967256555

offline

private
1



0
0
< p>And I just want to be able to access these values. My knowledge of XmlTextReaders is limited, which leaves me nowhere. Thank you.

XDocument doc = XDocument.Load("http://steamcommunity.com/profiles/76561197967256555/?xml=1");
string steamID64 = doc.Root.Descendants ("steamID64").First().Value;
string steamID = doc.Root.Descendants("steamID").First().Value;
string onlineState = doc.Root.Descendants(" onlineState").First().Value;
string stateMessage = doc.Root.Descendants("stateMessage").First().Value;
string privacyState = doc.Root.Descendants("privacyState" ).First().Value;
string visibilityState = doc.Root.Descendants("visibilityState").First().Value;
string avatarIcon = doc.Root.Descendants("avatarIcon"). First().Value;
string avatarMedium = doc.Root.Descendants("avatarMedium").First().Value;
string avatarFull = doc.Root.Descendants("avatarFull").First( ).Value;
string vacBanned = doc.Root.Descendants("vacBanned").First().Value;
string isLimitedAccount = doc.Root.Descendants("isLimitedAccount").First().Value;

I want to read an XML file located here

The data looks like this

 < br /> 76561197967256555 

offline

private
1



0
0

and I just want to be able to access these values. My knowledge of XmlTextReaders is limited, which leaves me nowhere. Thank you.

XDocument doc = XDocument .Load("http://steamcommunity.com/profiles/76561197967256555/?xml=1");
string steamID64 = doc.Root.Descendants("steamID64").First().Value;
string steamID = doc.Root.Descendants("steamID").First().Value;
string onlineState = doc.Root.Descendants("onlineState").First().Value;
string stateMessage = doc.Root.Descendants("stateMessage").First().Value;
string privacyState = doc.Root.Descendants("privacyState").First().Value;
string visibilityState = doc.Root.Descendants("visibilityState").First().Value;
string avatarIcon = doc.Root.Descendants("avatarIcon").First().Value;
string avatarMedium = doc. Root.Descendants("avatarMedium").First().Value;
string avatarFull = doc.Root.Descendants("avatarFull").First().Value;
string vacBanned = doc.Root.Descendants("vacBanned").First().Value;
string isLimitedAccount = doc.Root.Descendants("isLimitedAccount").First().Value;

Leave a Comment

Your email address will not be published.