private static void LoadTradersFromNodes(XmlNodeList nodes) { foreach (XmlNode node in nodes) { Trader trader = new Trader(node.GetXmlAttributeAsInt("ID"), node.SelectSingleNode("./Name")?.InnerText ?? "", node.GetXmlAttributeAsBool("HasWeapons")); foreach (XmlNode childNode in node.SelectNodes("./InventoryItems/Item")) { trader.AddItemToInventory(ItemFactory.CreateGameItem(childNode.GetXmlAttributeAsInt("ID")), childNode.GetXmlAttributeAsInt("Quantity")); } foreach (XmlNode childNode in node.SelectNodes("./Weapons/Weapon")) { trader.AddWeaponToWeapons(WeaponFactory.CreateWeapon(childNode.GetXmlAttributeAsInt("ID"))); } AddTraderToList(trader); } }