JavaScript appears to be disabled. We recommend you enable JavaScript while visiting this site.

(All original content on this site is licensed under the Creative Commons License Attribution-Noncommercial-No Derivative Works 3.0.)

Nier weapon data in XML (and LINQ sample query)

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(@"http://media.jamesrskemp.com/xml/NierWeapons.xml");

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;}

Tags: , , ,

Categories: gaming

blog comments powered by Disqus