[Mono-list] Probleme with XML

Andreas Färber andreas.faerber at web.de
Sat Aug 19 04:38:32 EDT 2006


Am 19.08.2006 um 07:48 schrieb Julien Sobrier:

> Hello,
> I have an XML that looks like this (simplified):
> <schemafile>
>     <schemalist module="xxxx">
>         <schema>
>             ...
>         </schema>
>         <schema>
>             ....
>         <schema>
>     </schemalist>
> </schemafile>
>
> I have the corresponding C# objects (simplified also):
>
> [XmlRoot("schemafile")]
> public class Schemafile
> {
>     private Module module;
>     [XmlElement("schemalist", typeof(Module))]
>     public Module ModuleName
>     {
>         get { return module; }
>         set { module = value; }
>     }
> }
>
>
> public class Module
> {
>     [XmlElement("schema", typeof(Setting))]
>     public ArrayList SchemaList = new ArrayList();

Try XmlArrayAttribute above. You're trying the map a single element  
to an ArrayList.

Andreas

>     [XmlAttribute("module", typeof(string))]
>     public string Name
>     {
>         get { return name; }
>         set { name = value;}
>     }
> }
>
>  public class Setting
> {
>     ...
> }
>
>
> The object Schemafile is created with the right ModuleName. Module is
> created with the right Name, but SchemaList is empty. Setting is  
> created
> correctly.
>
> Every time I have something like this, ArrayList is always empty:
> XmlElement("element", typeof(Element))]
> public ArrayList SomeList = new ArrayList();
>
> I don't know what I am missing. I couldn't find similar examples on  
> the web.
>
> Thank you
> Julien
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list



More information about the Mono-list mailing list