Search code examples
c#asp.netxmlxmlreaderxmltextreader

XML Reader Performance


I've traced slugishness in my application to the bit of code that's being timed below. I knew that this would be a slow point but each request is taking an average of 1 second. The bit of xml that I'm after is always in the first tag so I don't think it's the download times that are getting me.

Stopwatch stopwatch = new Stopwatch();
XmlTextReader reader = new XmlTextReader("http://steamcommunity.com/id/test?xml=1");

stopwatch.Reset();
stopwatch.Start();

while (reader.Read()) {
 if (reader.Name.Equals("steamID64")) {
  reader.Read();

  stopwatch.Stop();

  time = stopwatch.ElapsedMilliseconds();
  return Convert.ToInt64(reader.Value);
 }
}

Is there a faster way to read the tag that I want or am I being limited by the server I'm downloading the xml files from?

Thanks.


Solution

  • so I don't think it's the download times that are getting me

    To confirm this have you considered downloading the file locally and then seeing what the times are like