If have this simple xml document content:
<systemconfig>
<systemmenustyle>Standard</systemmenustyle>
<desktopviewstyle>Office2007</desktopviewstyle>
<windowstate>Maximized</windowstate>
<statusbarState>Hide</statusbarState>
</systemconfig>
My code of reading it using C# is:
FileStream MCConfigFile = new FileStream("MachineConfig.xml", FileMode.Open);
XmlTextReader MCConfigReader = new XmlTextReader(MCConfigFile);
MCConfigReader.WhitespaceHandling = WhitespaceHandling.Significant;
while (MCConfigReader.Read())
{
switch (MCConfigReader.NodeType)
{
case (XmlNodeType.Element):
switch (MCConfigReader.Name)
{
case "systemmenustyle":
myMachineConfig.systemMenuStyle = MCConfigReader.ReadElementString();
break;
case "desktopviewstyle":
myMachineConfig.desktopViewStyle = MCConfigReader.ReadElementString();
break;
case "windowstate":
myMachineConfig.windowState = MCConfigReader.ReadElementString();
break;
case "statusbarstate":
myMachineConfig.statusbarState = MCConfigReader.ReadElementString();
break;
default:
break;
}
break;
case (XmlNodeType.EndElement):
break;
default:
break;
}
}
MCConfigReader.Close();
MCConfigFile.Close();
My problem is that it does not read the desktopviewstyle and statusbarstate as element but as text which causes not to get through the correct line of code inside the switch case XmlNodeTyle.Element.
Am I missing something here folks?
JESS S. BANAGA
Project Leader - SDD division
...shifting from VFP to C#.Net
CHARISMA simply means: "Be more concerned about making others feel good about themselves than you are in making them feel good about you."