public static Board xmlToBoard(XElement boardXML) { checkOrderOfTagsFromXML(new List <string> { "map", "map" }, boardXML.Elements().ToList()); Board board = new Board(); int col = -1; int row = -1; XElement tilesXML = boardXML.Elements("map").ElementAt(0); XElement pawnsXML = boardXML.Elements("map").ElementAt(1); //create board with tiles placed in correct grid position foreach (XElement ent in tilesXML.Elements("ent")) { try { col = Int32.Parse(ent.Descendants("x").ElementAt(0).Value); row = Int32.Parse(ent.Descendants("y").ElementAt(0).Value); } catch (FormatException e) { Console.WriteLine(e.Message); } Tile tile = xmlToTile(ent.Descendants("tile").ElementAt(0)); board.grid[row, col] = tile; } // create pawns (aka onboard players) foreach (XElement ent in pawnsXML.Elements("ent")) { checkOrderOfTagsFromXML(new List <string> { "color", "pawn-loc" }, ent.Elements().ToList()); string color = ent.Element("color").Value; List <Posn> possiblePosns = xmlToPosn(ent.Element("pawn-loc")); Posn startPos = pawnLocToPosn(possiblePosns, board); SPlayer tempPlayer = new SPlayer(); tempPlayer.setColor(color); tempPlayer.setPosn(startPos); board.addPlayerToBoard(tempPlayer); } return(board); }