private void ParseDom(IXmlDocument dom)
{
var root = dom.DocumentElement;
if (root == null) return;
// the XML uses IDs for referring elements within the
// model. Therefore we do the parsing in 2 steps:
// - at first we read all model elements and store them by ID in a lookup table
// - after that we need to join up the information.
if (root.LocalName == "GPIF")
{
Score = new Score();
// parse all children
root.IterateChildren(n =>
{
if (n.NodeType == XmlNodeType.Element)
{
switch (n.LocalName)
{
case "Score":
ParseScoreNode(n);
break;
case "MasterTrack":
ParseMasterTrackNode(n);
break;
case "Tracks":
ParseTracksNode(n);
break;
case "MasterBars":
ParseMasterBarsNode(n);
break;
case "Bars":
ParseBars(n);
break;
case "Voices":
ParseVoices(n);
break;
case "Beats":
ParseBeats(n);
break;
case "Notes":
ParseNotes(n);
break;
case "Rhythms":
ParseRhythms(n);
break;
}
}
});
}
else
{
throw new UnsupportedFormatException();
}
BuildModel();
}