Nier weapon data in XML (and LINQ sample query)

  • October 16, 2011
  • James Skemp
  • gaming

Going through the game Nier yet again, I wanted an easier way to track what weapon levels I had already upgraded to, and what items I still needed to unlock weapon items.

Phase one towards that goal is creating an XML file with weapon upgrade information which is available online: Nier weapon data. An XML schema document for this information is also available: Nier weapon XSD.

Sample LINQ query

The following query can be run from LINQPAD, and will either display all items with their counts, or a grouped listing of items with the total quantity needed.

XDocument weaponsXml = XDocument.Load(@“");

var items = weaponsXml .Descendants() .Elements(“Item”) .Select(i => new WeaponItem { Name = i.Attribute(“Name”).Value, Quantity = i.Attribute(“Quantity”) != null ? int.Parse(i.Attribute(“Quantity”).Value) : 1 }) .OrderBy(i => i.Name).ThenBy(i => i.Quantity) ;

var itemsGrouped = items.GroupBy(i => i.Name).Select(g => new WeaponItem { Name = g.Key, Quantity = g.Sum(i => i.Quantity) });

//items.Dump(); itemsGrouped.Dump();

} public class WeaponItem { public string Name {get;set;} public int Quantity {get;set;}