Skip to content

Instantly share code, notes, and snippets.

@bertwagner
Last active November 24, 2016 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bertwagner/c56c0d1859449a9269e26d4bd7e0a26f to your computer and use it in GitHub Desktop.
Save bertwagner/c56c0d1859449a9269e26d4bd7e0a26f to your computer and use it in GitHub Desktop.
Method for parsing XML using XmlReader
public static void XmlReaderTest(string filePath)
{
// We create storage for ids of all of the rows from users where reputation == 1
List<string> singleRepRowIds = new List<string>();
using (XmlReader reader = XmlReader.Create(filePath))
{
while (reader.Read())
{
if (reader.IsStartElement())
{
if (reader.Name == "row" && reader.GetAttribute("Reputation") == "1")
{
singleRepRowIds.Add(reader.GetAttribute("Id"));
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment