Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can't get the right element.
Message
De
20/11/2006 04:22:45
 
Information générale
Forum:
ASP.NET
Catégorie:
XML
Divers
Thread ID:
01171088
Message ID:
01171111
Vues:
8
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?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform