KB: How to read an XML file

// reading
XMLBreezeDocument doc = XMLBreeze.Load("c:\myfile.xml", false);
if (doc.RootNode != null)
{
    if (doc.RootNode.Attributes.Exists("window_state"))
        this.MainWindowState = (doc.RootNode.Attributes["window_state"] == "Maximized" ? FormWindowState.Maximized : FormWindowState.Normal);
    
    // read in options
    if (doc.RootNode.Nodes.Exists("Options"))
    {
        XMLBreezeNode optionsNode = doc.RootNode.Nodes["Options"];
        
        if (optionsNode.Attributes.Exists("Theme"))
        {
            int intVal = 0;
            Int32.TryParse(optionsNode.Attributes["Theme"], out intVal);
            this.Theme = (ThemeType)intVal;
        }
        else
            this.Theme = ThemeType.Light;
        
        if (optionsNode.Attributes.Exists("CheckForUpdateOnStartup"))
            this.CheckForUpdates = Convert.ToBoolean(optionsNode.Attributes["CheckForUpdateOnStartup"]);
        else
            this.CheckForUpdates = true;
    }
}

See Also