Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can't get the right element.
Message
From
20/11/2006 04:22:45
 
General information
Forum:
ASP.NET
Category:
XML
Miscellaneous
Thread ID:
01171088
Message ID:
01171111
Views:
7
Hi,

Use ReadString() instead of ReadElementString()
HTH,
Viv

>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?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform