Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can't get the right element.
Message
 
 
General information
Forum:
ASP.NET
Category:
XML
Miscellaneous
Thread ID:
01171088
Message ID:
01171306
Views:
6
Hi Viv!

Thank you very much! I works perfect now...

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

Click here to load this message in the networking platform