.net - Retaining order of the xml elements between serialization and deserialization in C# -


i have generated c# class xml schema. class used in tool perform following:

  1. read xml deserializing
  2. make changes deserialized object.
  3. write processed deserialized object xml serializing.

basically fill data in xml.

i have problems in retaining order of elements between deserialization , serialization.

i have sample code below. fpnodetypewindowfield , fpnodetypeclass1field can appear interchangeably in 2 xmls. order of these fields not fixed in xml. don't face problems while reading xml while deserializing. order of these fields follow order mentioned in code.

is there possible solution retain order of these fields in xml?

/// <remarks/> [system.codedom.compiler.generatedcodeattribute("xsd", "4.0.30319.1")] [system.serializableattribute()] [system.diagnostics.debuggerstepthroughattribute()] [system.componentmodel.designercategoryattribute("code")] [system.xml.serialization.xmltypeattribute(anonymoustype = true)] [system.xml.serialization.xmlrootattribute(namespace = "", isnullable = false)] public partial class fpnodetypeclass {      private string helptextfield;      private fpxfptreefpnodetyperootfpnodetypewindow[] fpnodetypewindowfield;      private fpnodetypeclass[] fpnodetypeclass1field;      private string namefield;      /// <remarks/>     [system.xml.serialization.xmlelementattribute(form = system.xml.schema.xmlschemaform.unqualified)]     public string helptext     {                 {             return this.helptextfield;         }         set         {             this.helptextfield = value;         }     }      /// <remarks/>     [system.xml.serialization.xmlelementattribute("fpnodetypewindow")]     public fpxfptreefpnodetyperootfpnodetypewindow[] fpnodetypewindow     {                 {             return this.fpnodetypewindowfield;         }         set         {             this.fpnodetypewindowfield = value;         }     }      /// <remarks/>     [system.xml.serialization.xmlelementattribute("fpnodetypeclass")]     public fpnodetypeclass[] fpnodetypeclass1     {                 {             return this.fpnodetypeclass1field;         }         set         {             this.fpnodetypeclass1field = value;         }     }      /// <remarks/>     [system.xml.serialization.xmlattributeattribute()]     public string name     {                 {             return this.namefield;         }         set         {             this.namefield = value;         }     } } 

i found out myself order can fixed while serialization. can't dynamic.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -