0

I am trying to read an xml using xml serialzation

however when I am trying to read the XML I am getting that the list of items called "Project" on my xml is empty. however I have quite a lot of them.

I think the problem in my code is how I describe my XML into structure.

I am attaching my xml and my code would be happy for assistant.

XML:

<MotProjects>
<Project name="IAR-PROJECT_PM_COMPLETE_PARTITION_2 -&gt; M65_COMPLETE_JS702159_Release_vB17.110" exec="0">
<Defines name="PROJECT_PM_TYPE = PROJECT_PM_LE_PARTITION_2,SOFTWARE_TYPE = RELEASE_VER" />
<Make name="C:\p4client\System\PowerMax_PRO\src\project\IAR Project\PM_Pro.ewp" />
<Include name="C:\p4client\System\PowerMax_PRO\src\sw_def.h" />
<Ref_mot name="C:\P4client\System\PowerMax_PRO\bin\PM-LE\part-II\B17.110\Release\M65_COMPLETE_JS702159_Release_vB17.110.mot" />
<Folder name="C:\p4client\System\PowerMax_PRO\src\project\IAR Project\Project_Release_256k\Exe" />
<MotCommand name="C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4\common\bin\IarBuild.exe" />
<Param4MotCommand name="-build Project_Release_256k PM_Pro_256k.mot" />
<ExtraDefine name="" />
<MotImage name="" exec="2">
  <Boot_path name="" />
  <Rsu_path name="" />
  <Release_path name="" />
  <Image_path name="" />
  <Catalog_number name="" />
  <Additional_text name="" />
</MotImage>
<Package name="" exec="3">
  <Release_path name="" />
  <Rsu_path name="" />
  <Migration_path name="" />
  <Default_path name="" />
  <Old_Release_path name="" />
  <Old_Default_path name="" />
  <Package_path name="" />
  <Catalog_number name="" />
  <Additional_text name="" />
</Package>
<MigrationAndDevicesBin name="new MigrationAndDevicesBin project" exec="4">
  <Migration id="0" productType="PMAX" swVersion="00.00.00" pathname="" />
  <Device id="1" productType="IOV" swVersion="" pathname="" />
  <Device id="2" productType="EXP33" swVersion="" pathname="" />
  <Device id="3" productType="KP250" swVersion="" pathname="" />
  <Device id="4" productType="" swVersion="" pathname="" />
  <Device id="5" productType="" swVersion="" pathname="" />
  <Catalog_number name="JS######" />
  <OutputFile pathname="" />
</MigrationAndDevicesBin>
<SerialFlashHexImage name="new SerialFlashHexImage project" exec="5">
  <File id="0" fileType="RSU" pathname="" />
  <File id="1" fileType="Main" pathname="" />
  <File id="2" fileType="Default" pathname="" />
  <File id="3" fileType="MIG" pathname="" />
  <Catalog_number name="JS######" />
  <OutputFile pathname="" />
</SerialFlashHexImage>
<Flasher name="CreateHexFile" exec="6">
  <Item name="port" value="" />
  <Item name="default_mot_file_full_path" value="" />
  <Item name="flasher_exe_full_path" value="" />
</Flasher>
</Project>
<Project name="IAR-PROJECT_DEFAULT_GENERAL_PM_LE_PARTITION_2 -&gt; M65_JXXXXXX-vB17.110_PartII_gen" exec="0">
<Defines name="PROJECT_PM_TYPE = PROJECT_PM_LE_PARTITION_2,SOFTWARE_TYPE = DOWNLOAD_VER,PROJECT_PM_DEFAULT_TYPE = GEN_GSM_DEF" />
<Make name="C:\p4client\System\PowerMax_PRO\src\project\IAR Project\PM_Pro.ewp" />
<Include name="C:\p4client\System\PowerMax_PRO\src\sw_def.h" />
<Ref_mot name="C:\p4client\System\PowerMax_PRO\bin\PM-LE\part-II\B17.110\Special\MOT\M65_JXXXXXX-vB17.110_PartII_gen.mot" />
<Folder name="C:\p4client\System\PowerMax_PRO\src\project\IAR Project\Download_Release_256k\Exe" />
<MotCommand name="C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4\common\bin\IarBuild.exe" />
<Param4MotCommand name="-build Download_Release_256k PM_Pro_Download_256k.mot" />
<ExtraDefine name="" />
<MotImage name="" exec="2">
  <Boot_path name="" />
  <Rsu_path name="" />
  <Release_path name="" />
  <Image_path name="" />
  <Catalog_number name="" />
  <Additional_text name="" />
 </MotImage>
<Package name="" exec="3">
  <Release_path name="" />
  <Rsu_path name="" />
  <Migration_path name="" />
  <Default_path name="" />
  <Old_Release_path name="" />
  <Old_Default_path name="" />
  <Package_path name="" />
  <Catalog_number name="" />
  <Additional_text name="" />
</Package>
<MigrationAndDevicesBin name="new MigrationAndDevicesBin project" exec="4">
  <Migration id="0" productType="PMAX" swVersion="00.00.00" pathname="" />
  <Device id="1" productType="IOV" swVersion="" pathname="" />
  <Device id="2" productType="EXP33" swVersion="" pathname="" />
  <Device id="3" productType="KP250" swVersion="" pathname="" />
  <Device id="4" productType="" swVersion="" pathname="" />
  <Device id="5" productType="" swVersion="" pathname="" />
  <Catalog_number name="JS######" />
  <OutputFile pathname="" />
</MigrationAndDevicesBin>
<SerialFlashHexImage name="new SerialFlashHexImage project" exec="5">
  <File id="0" fileType="RSU" pathname="" />
  <File id="1" fileType="Main" pathname="" />
  <File id="2" fileType="Default" pathname="" />
  <File id="3" fileType="MIG" pathname="" />
  <Catalog_number name="JS######" />
  <OutputFile pathname="" />
</SerialFlashHexImage>
<Flasher name="CreateHexFile" exec="6">
  <Item name="port" value="" />
  <Item name="default_mot_file_full_path" value="" />
  <Item name="flasher_exe_full_path" value="" />
</Flasher>
</Project>
</MotProjects>

C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Xml;
using System.Xml.Serialization;

namespace XMLParser
{
[XmlRoot("MotProjects")]
public class XMLStructure
{

    [XmlArrayItem("Project")]
    List<Project> LProject;

    public XMLStructure()
    {
        LProject = new List<Project>();

    }

    public class  Project
    {
        [XmlAttribute("name")]
        public string name;

        [XmlAttribute("exec")]
        public string exec;


        [XmlElement("Include")]
        public NameElement Include;

        [XmlElement("Ref_mot")]
        public NameElement Ref_mot;

        [XmlElement("Folder")]
        public NameElement Folder;

        [XmlElement("MotCommand")]
        public NameElement MotCommand;

        [XmlElement("Param4MotCommand")]
        public NameElement Param4MotCommand;

        [XmlElement("ExtraDefine")]
        public NameElement ExtraDefine;

        [XmlElement("Package")]
        public Package MYPackage;

        [XmlElement("MotImage")]
        public MotImage Mot_Image;


        [XmlElement("MigrationAndDevicesBin")]
        public MigrationAndDevicesBin _MigrationAndDevicesBin;

        [XmlElement("SerialFlashHexImage")]
        public SerialFlashHexImage MYSerialFlashHexImage;

        [XmlElement("Flasher")]
        public Flasher MFlasher;



        public Project()
        {
            name = "";
            exec = "";
            Include = new NameElement();
            Ref_mot = new NameElement();
            Folder = new NameElement();
            MotCommand = new NameElement();
            Param4MotCommand = new NameElement();
            ExtraDefine = new NameElement();
            Mot_Image = new MotImage();
            MYPackage = new Package();
            _MigrationAndDevicesBin = new MigrationAndDevicesBin();
            MYSerialFlashHexImage = new SerialFlashHexImage ();
            MFlasher = new Flasher();
        }



         public class NameElement 
         {
             [XmlElement("name")]
             public string name;


             public NameElement()
             {
                 name = "";
             }

         }

         public class MotImage
         {
             [XmlAttribute("name")]
             public string name;

             [XmlAttribute("exec")]
             public string exec;

             [XmlElement("Boot_path")]
             public NameElement Boot_path;

             [XmlElement("Rsu_path")]
             public NameElement Rsu_path;

             [XmlElement("Release_path")]
             public NameElement Release_path;

             [XmlElement("Image_path")]
             public NameElement Image_path;

             [XmlElement("Catalog_number")]
             public NameElement Catalog_number;

             [XmlElement("Additional_text")]
             public NameElement Additional_text;


             public MotImage()
             {
                 name = "";
                 exec = "";
                 Boot_path = new NameElement();
                 Rsu_path = new NameElement();
                 Release_path = new NameElement();
                 Image_path = new NameElement();
                 Catalog_number = new NameElement();
                 Additional_text = new NameElement();
             }

             public class NameElement
             {
                 [XmlElement("name")]
                 public string name;

                 public NameElement()
                 {
                     name = "";
                 }

             }
         }


         public class Package
         {


             [XmlAttribute("name")]
             public string name;

             [XmlAttribute("exec")]
             public string exec;

             [XmlAttribute("Release_path")]
             public NameElement Release_path;

             [XmlAttribute("Rsu_path")]
             public NameElement Rsu_path;

             [XmlElement("Migration_path")]
             public NameElement Migration_path;

             [XmlElement("Default_path")]
             public NameElement Default_path;

             [XmlElement("Old_Release_path")]
             public NameElement Old_Release_path;

             [XmlElement("Old_Default_path")]
             public NameElement Old_Default_path;

             [XmlElement("Package_path")]
             public NameElement Package_path;

             [XmlElement("Additional_text")]
             public NameElement Additional_text;

             [XmlElement("Catalog_number")]
             public NameElement Catalog_number;

             public Package()
             {
                 name = "";
                 exec = "";
                 Release_path = new NameElement();
                 Rsu_path = new NameElement();
                 Migration_path = new NameElement();
                 Default_path = new NameElement();
                 Old_Default_path = new NameElement();
                 Old_Release_path = new NameElement();
                 Rsu_path = new NameElement();
                 Release_path = new NameElement();                    
                 Catalog_number = new NameElement();
                 Additional_text = new NameElement();
             }

             public class NameElement
             {
                 [XmlElement("name")]
                 public string name;

                 public NameElement()
                 {
                     name = "";
                 }

             }
         }


         public class MigrationAndDevicesBin
         {
             [XmlAttribute("name")]
             public string name;

             [XmlAttribute("exec")]
             public string exec;

             [XmlArray("Device")]
             public List<Device> _Device;

             [XmlElement("Catalog_number")]
             public NameElement Catalog_number;

             [XmlElement("OutputFile")]
             public OutputFile OutPutFile;

             public MigrationAndDevicesBin()
             {
                 name = "";
                 exec = "";
                 _Device = new List<Device>();
                 Catalog_number = new NameElement();
                 OutPutFile = new OutputFile();
             }
         }

         public class Device
         {


             [XmlAttribute("id")]
             public string id;

             [XmlAttribute("productType")]
             public string productType;

             [XmlAttribute("swVersion")]
             public string swVersion;

             [XmlAttribute("pathname")]
             public string pathname;


             public Device()
             {
                 id = "";
                 productType = "";
                 swVersion = "";
                 pathname = "";



             }

         }


         public class OutputFile
         {

             [XmlElement("pathname")]
             public string pathname;

             public OutputFile()
             {
                 pathname = "";
             }

         }


         public class SerialFlashHexImage
         {
                           [XmlAttribute("name")]
             public string name;

             [XmlAttribute("exec")]
             public string exec;

             public SerialFlashHexImage()
             {
                name="";
                 exec="";
             }

             public class File
             {
                 [XmlAttribute("name")]
                 public string name;

                 [XmlAttribute("exec")]
                 public string exec;

                 [XmlAttribute("id")]
                 public string id;

                 [XmlAttribute("fileType")]
                 public string fileType;

                 [XmlAttribute("pathname")]
                 public string pathname;

                 [XmlElement("OutputFile")]
                 public OutputFile OutputFile;

                 [XmlElement("Catalog_number")]
                 public NameElement Catalog_number; 


                 public File()
                 {
                     name = "";
                     exec = "";
                     id = "";
                     fileType = "";
                     pathname = "";
                     OutputFile = new OutputFile();
                     Catalog_number = new NameElement();
                 }

             }

         }


         public class Flasher
         {

             [XmlArray("Item")]
             public Item items;

             public Flasher()
             {
                 items = new Item();
             }

             public class Item
             {

                 [XmlAttribute("name")]
                 public string name;

                 [XmlAttribute("value")]
                 public string value;


                 public Item()
                 {
                     name = "";
                     value = "";
                 }

             }

         }


    }


   }
  }

1 Answer 1

1

Your initial problem is as follows:

  1. Your List<Project> LProject; needs to be public, and to be marked with [XmlElement] to indicate it should be serialized without an outer container element:

    // Fixed - made public and marked with [XmlElement]
    [XmlElement("Project")]
    public List<Project> LProject;
    

    XmlSerializer only serializes public properties and fields, even if marked with an XML serialization attribute.

However, after I had fixed this and attempted to deserialize the sample XML, I found many more problems:

  1. There were several duplicate copies of the type NameElement throughout your class hierarchy. This causes XmlSerializer to throw the following exception:

    // InnerException: System.InvalidOperationException
    // Message="Types 'Question42409171.XMLStructure.Project.Package.NameElement' and 'Question42409171.XMLStructure.Project.NameElement' both use the XML type name, 'NameElement', from namespace ''. Use XML attributes to specify a unique XML name and/or namespace for the type."
    

    The solution is to eliminate the duplicates and retain one single definition:

    // Fixed - removed duplicates.
    // InnerException: System.InvalidOperationException
    // Message="Types 'Question42409171.XMLStructure.Project.Package.NameElement' and 'Question42409171.XMLStructure.Project.NameElement' both use the XML type name, 'NameElement', from namespace ''. Use XML attributes to specify a unique XML name and/or namespace for the type."
    public class NameElement 
    {
        // Fixed
        // This was marked as an element but should be an attribute
        [XmlAttribute("name")]
        public string name;
    
        public NameElement()
        {
            name = "";
        }
    }
    
  2. In NameElement, name should be marked with [XmlAttribute] not [XmlElement], as shown above.

  3. Several properties are missing from Project:

        // Fixed missing property
        [XmlElement("Defines")]
        public NameElement Defines;
    
        // Fixed missing property
        [XmlElement("Make")]
        public NameElement Make;
    
        // Fixed missing property
        [XmlElement("Include")]
        public NameElement Include;
    
  4. In Package several complex properties are marked with [XmlAttribute]. Only simple properties (those that can be converted to strings) can be so marked. These properties need to be marked with [XmlElement]:

            // InnerException: System.InvalidOperationException
            // Message="Cannot serialize member 'Release_path' of type Question42409171.XMLStructure.Project.Package.NameElement. XmlAttribute/XmlText cannot be used to encode complex types."
            [XmlElement("Release_path")]
            public NameElement Release_path;
    
            // Fixed
            // InnerException: System.InvalidOperationException
            // Message="Cannot serialize member 'Rsu_path' of type Question42409171.XMLStructure.NameElement. XmlAttribute/XmlText cannot be used to encode complex types."
            [XmlElement("Rsu_path")] // Fixed 
            public NameElement Rsu_path;
    
  5. In MigrationAndDevicesBin the property _Device needs to be marked with [XmlElement] not [XmlArray]:

        public class MigrationAndDevicesBin
        {
            [XmlAttribute("name")]
            public string name;
    
            [XmlAttribute("exec")]
            public string exec;
    
            // Fixed - should be [XmlElement]
            [XmlElement("Device")]
            public List<Device> _Device;
    
  6. In SerialFlashHexImage the nested type File was never even used. A property public List<File> Files { get; set; } is required:

        public class SerialFlashHexImage
        {
            [XmlAttribute("name")]
            public string name;
    
            [XmlAttribute("exec")]
            public string exec;
    
            // Fixed - the type File was not even used!
            [XmlElement("File")]
            public List<File> Files { get; set; }
    
            public SerialFlashHexImage()
            {
                this.Files = new List<File>();
                name = "";
                exec = "";
            }
    
  7. In Flasher, properties corresponding to name and exec are missing:

        public class Flasher
        {
            // Fixed - missing attribute
            [XmlAttribute("name")]
            public string name;
    
            // Fixed - missing attribute
            [XmlAttribute("exec")]
            public string exec;
    
  8. Also in Flasher, items needs to be a collection, not a singleton:

        public class Flasher
        {
            //Fixed
            //InnerException: System.InvalidOperationException
            //Message="For non-array types, you may use the following attributes: XmlAttribute, XmlText, XmlElement, or XmlAnyElement."
            [XmlElement("Item")]
            public List<Item> items;
    

And that is as far as I got. Sample fiddle. The XML can be loaded successfully and most of the data appears to be present, but I did not debug it completely as doing so is outside the scope of a stackoverflow question.

Quite honestly, that's too many problems. I recommend you abandon this attempt to manually create c# classes to deserialize this XML, and instead create classes using an automated code-generation tool such as https://xmltocsharp.azurewebsites.net/ or Paste XML as Classes.

Here are my final modifications to your types:

[XmlRoot("MotProjects")]
public class XMLStructure
{
    // Fixed - made public and marked with [XmlElement]
    [XmlElement("Project")]
    public List<Project> LProject;

    public XMLStructure()
    {
        LProject = new List<Project>();
    }

    // Fixed - removed duplicates.
    // InnerException: System.InvalidOperationException
    // Message="Types 'Question42409171.XMLStructure.Project.Package.NameElement' and 'Question42409171.XMLStructure.Project.NameElement' both use the XML type name, 'NameElement', from namespace ''. Use XML attributes to specify a unique XML name and/or namespace for the type."
    public class NameElement 
    {
        // Fixed
        // This was marked as an element but should be an attribute
        [XmlAttribute("name")]
        public string name;

        public NameElement()
        {
            name = "";
        }
    }

    public class Project
    {
        [XmlAttribute("name")]
        public string name;

        [XmlAttribute("exec")]
        public string exec;

        // Fixed missing property
        [XmlElement("Defines")]
        public NameElement Defines;

        // Fixed missing property
        [XmlElement("Make")]
        public NameElement Make;

        // Fixed missing property
        [XmlElement("Include")]
        public NameElement Include;

        [XmlElement("Ref_mot")]
        public NameElement Ref_mot;

        [XmlElement("Folder")]
        public NameElement Folder;

        [XmlElement("MotCommand")]
        public NameElement MotCommand;

        [XmlElement("Param4MotCommand")]
        public NameElement Param4MotCommand;

        [XmlElement("ExtraDefine")]
        public NameElement ExtraDefine;

        [XmlElement("Package")]
        public Package MYPackage;

        [XmlElement("MotImage")]
        public MotImage Mot_Image;

        [XmlElement("MigrationAndDevicesBin")]
        public MigrationAndDevicesBin _MigrationAndDevicesBin;

        [XmlElement("SerialFlashHexImage")]
        public SerialFlashHexImage MYSerialFlashHexImage;

        [XmlElement("Flasher")]
        public Flasher MFlasher;

        public Project()
        {
            name = "";
            exec = "";
            Include = new NameElement();
            Ref_mot = new NameElement();
            Folder = new NameElement();
            MotCommand = new NameElement();
            Param4MotCommand = new NameElement();
            ExtraDefine = new NameElement();
            Mot_Image = new MotImage();
            MYPackage = new Package();
            _MigrationAndDevicesBin = new MigrationAndDevicesBin();
            MYSerialFlashHexImage = new SerialFlashHexImage();
            MFlasher = new Flasher();
        }

        public class MotImage
        {
            [XmlAttribute("name")]
            public string name;

            [XmlAttribute("exec")]
            public string exec;

            [XmlElement("Boot_path")]
            public NameElement Boot_path;

            [XmlElement("Rsu_path")]
            public NameElement Rsu_path;

            [XmlElement("Release_path")]
            public NameElement Release_path;

            [XmlElement("Image_path")]
            public NameElement Image_path;

            [XmlElement("Catalog_number")]
            public NameElement Catalog_number;

            [XmlElement("Additional_text")]
            public NameElement Additional_text;

            public MotImage()
            {
                name = "";
                exec = "";
                Boot_path = new NameElement();
                Rsu_path = new NameElement();
                Release_path = new NameElement();
                Image_path = new NameElement();
                Catalog_number = new NameElement();
                Additional_text = new NameElement();
            }
        }

        public class Package
        {
            [XmlAttribute("name")]
            public string name;

            [XmlAttribute("exec")]
            public string exec;

            // Fixed
            // InnerException: System.InvalidOperationException
            // Message="Cannot serialize member 'Release_path' of type Question42409171.XMLStructure.Project.Package.NameElement. XmlAttribute/XmlText cannot be used to encode complex types."
            [XmlElement("Release_path")]
            public NameElement Release_path;

            // Fixed
            // InnerException: System.InvalidOperationException
            // Message="Cannot serialize member 'Rsu_path' of type Question42409171.XMLStructure.NameElement. XmlAttribute/XmlText cannot be used to encode complex types."
            [XmlElement("Rsu_path")] // Fixed 
            public NameElement Rsu_path;

            [XmlElement("Migration_path")]
            public NameElement Migration_path;

            [XmlElement("Default_path")]
            public NameElement Default_path;

            [XmlElement("Old_Release_path")]
            public NameElement Old_Release_path;

            [XmlElement("Old_Default_path")]
            public NameElement Old_Default_path;

            [XmlElement("Package_path")]
            public NameElement Package_path;

            [XmlElement("Additional_text")]
            public NameElement Additional_text;

            [XmlElement("Catalog_number")]
            public NameElement Catalog_number;

            public Package()
            {
                name = "";
                exec = "";
                Release_path = new NameElement();
                Rsu_path = new NameElement();
                Migration_path = new NameElement();
                Default_path = new NameElement();
                Old_Default_path = new NameElement();
                Old_Release_path = new NameElement();
                Rsu_path = new NameElement();
                Release_path = new NameElement();
                Catalog_number = new NameElement();
                Additional_text = new NameElement();
            }
        }

        public class MigrationAndDevicesBin
        {
            [XmlAttribute("name")]
            public string name;

            [XmlAttribute("exec")]
            public string exec;

            // Fixed - should be [XmlElement]
            [XmlElement("Device")]
            public List<Device> _Device;

            [XmlElement("Catalog_number")]
            public NameElement Catalog_number;

            [XmlElement("OutputFile")]
            public OutputFile OutPutFile;

            public MigrationAndDevicesBin()
            {
                name = "";
                exec = "";
                _Device = new List<Device>();
                Catalog_number = new NameElement();
                OutPutFile = new OutputFile();
            }
        }

        public class Device
        {
            [XmlAttribute("id")]
            public string id;

            [XmlAttribute("productType")]
            public string productType;

            [XmlAttribute("swVersion")]
            public string swVersion;

            [XmlAttribute("pathname")]
            public string pathname;


            public Device()
            {
                id = "";
                productType = "";
                swVersion = "";
                pathname = "";
            }
        }

        public class OutputFile
        {
            [XmlElement("pathname")]
            public string pathname;

            public OutputFile()
            {
                pathname = "";
            }
        }

        public class SerialFlashHexImage
        {
            [XmlAttribute("name")]
            public string name;

            [XmlAttribute("exec")]
            public string exec;

            // Fixed - the type File was not even used!
            [XmlElement("File")]
            public List<File> Files { get; set; }

            public SerialFlashHexImage()
            {
                this.Files = new List<File>();
                name = "";
                exec = "";
            }

            public class File
            {
                [XmlAttribute("name")]
                public string name;

                [XmlAttribute("exec")]
                public string exec;

                [XmlAttribute("id")]
                public string id;

                [XmlAttribute("fileType")]
                public string fileType;

                [XmlAttribute("pathname")]
                public string pathname;

                [XmlElement("OutputFile")]
                public OutputFile OutputFile;

                [XmlElement("Catalog_number")]
                public NameElement Catalog_number;

                public File()
                {
                    name = "";
                    exec = "";
                    id = "";
                    fileType = "";
                    pathname = "";
                    OutputFile = new OutputFile();
                    Catalog_number = new NameElement();
                }
            }
        }

        public class Flasher
        {
            // Fixed - missing attribute
            [XmlAttribute("name")]
            public string name;

            // Fixed - missing attribute
            [XmlAttribute("exec")]
            public string exec;

            //Fixed
            //InnerException: System.InvalidOperationException
            //Message="For non-array types, you may use the following attributes: XmlAttribute, XmlText, XmlElement, or XmlAnyElement."
            [XmlElement("Item")]
            public List<Item> items;

            public Flasher()
            {
                items = new List<Item>();
                name = "";
                exec = "";
            }

            public class Item
            {
                [XmlAttribute("name")]
                public string name;

                [XmlAttribute("value")]
                public string value;

                public Item()
                {
                    name = "";
                    value = "";
                }
            }
        }
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.