If possible, please make it read the
C# XML Help!
Hi, I was wondering how I could make C# read XML off a website. Also, the website I want it to read is http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag=experiment5x.
If possible, please make it read the through text. Thanks.
If possible, please make it read the
Jaish MathewsPosted May 29, 2010, 1:10 PM
Many ways. It's basic XML Parsing. Below I used one way to get the title.
WebClient client = new WebClient();
string URL = "http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag=experiment5x";
Stream data = client.OpenRead(URL);
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();
XmlDocument doc = new XmlDocument();
doc.LoadXml(s);
string title = doc.SelectSingleNode("XboxInfo/PresenceInfo/Title").InnerText;
data.Close();
reader.Close();
StevePosted May 28, 2010, 10:48 AM
Jaish MathewsPosted May 28, 2010, 1:10 AM
Use WebClient class like below. You will get exact out put in a variable. So you can modify it in your oen way.
WebClient client = new WebClient();
string URL = "http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag=experiment5x";
Stream data = client.OpenRead(URL);
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();
Console.WriteLine(s);
data.Close();
reader.Close();
StevePosted May 27, 2010, 11:48 PM
CrishPosted May 27, 2010, 11:44 PM
try below links..
http://www.codeproject.com/KB/XML/csreadxml1.aspx
http://www.c-sharpcorner.com/UploadFile/mahesh/ReadingXmlFile11142005002137AM/ReadingXmlFile.aspx
for reading " http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag=experiment5x" you need to use XMLHTTP object in ASP.Net
Don't forget to Mark Do you like this Answer that solved your problem!