Game Development Reference
In-Depth Information
<Cell><Data ss:Type="String">NathanDraco</Data></Cell>
<Cell><Data ss:Type="String">An adventurous lad</Data></Cell>
<Cell><Data ss:Type="Number">35.0</Data></Cell>
<Cell><Data ss:Type="Number">20.0</Data></Cell>
<Cell><Data ss:Type="Number">18.0</Data></Cell>
<Cell><Data ss:Type="String">Standard</Data></Cell>
<Cell><Data ss:Type="String">draco3.png</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas -microsoft-com:office:excel">
<Print>
<ValidPrinterInfo/>
<PaperSizeIndex>0</PaperSizeIndex>
<HorizontalResolution>-4</HorizontalResolution>
<VerticalResolution>-4</VerticalResolution>
</Print>
<ShowPageLayoutZoom/>
<PageLayoutZoom>100</PageLayoutZoom>
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>1</ActiveRow>
<RangeSelection>R2C1:R4C7</RangeSelection>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>
Listing 12.1. An example XML document (CharacterData.xml).
Now, there is a lot of metadata in the XML that is used by Excel, which is not
important to us. We need to skip all of these elements as we parse through the
document. The real data begins with the first <Row> element, which contains the
header fields. First, we'll need to create an index for these fields so that we can
map the subsequent row data. The C# code for this is is shown in Listing 12.2.
{
static List<CharacterData > characters = new List<CharacterData >();
static Dictionary<string, int> fields = new Dictionary<string,
int>();
static void Main (string[] args)
{
var x = new XmlDocument();
x.Load(args[0]);
XmlElement root = x.DocumentElement;
XmlNode node = null;
if (root.Name == "Workbook")
{
// Navigate to the Worksheet child node
node = root["Worksheet"];
// Navigate to the Table child node
Search WWH ::




Custom Search