Unable to serialize correctly- c#

Posted by ltech on Stack Overflow See other posts from Stack Overflow or by ltech
Published on 2010-04-19T17:31:27Z Indexed on 2010/04/19 21:43 UTC
Read the original article Hit count: 270

Filed under:

I had asked this Yesterday

If my xsd schema changes to

<xs:element name="Document" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
  <xs:sequence>
    <xs:element name="MetaDoc" minOccurs="0" maxOccurs="unbounded">
      <xs:complexType>
        <xs:sequence>
          <xs:element name="ATTRIBUTES" minOccurs="0" maxOccurs="unbounded">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="author" type="xs:string" minOccurs="0" />
                <xs:element name="max_versions" type="xs:string" minOccurs="0" />
                <xs:element name="summary" type="xs:string" minOccurs="0" />
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
      </xs:complexType>
    </xs:element>
  </xs:sequence>
</xs:complexType>
</xs:element>

My xsd -> class generation becomes

 /// <remarks/>
[System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
[System.Xml.Serialization.XmlArrayItemAttribute("MetaDoc", typeof(DocumentMetaDocATTRIBUTES[]), Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
[System.Xml.Serialization.XmlArrayItemAttribute("ATTRIBUTES", typeof(DocumentMetaDocATTRIBUTES), Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false, NestingLevel=1)]
public DocumentMetaDocATTRIBUTES[][][] Document {
    get {
        return this.documentField;
    }
    set {
        this.documentField = value;
    }
}

If I am deriving to CollectionBase, as shown in my previous post, how would I manage the XmlArrayItemAttribute ? so that I can read this part of my input xml into my strongly types object

    <Document>
   <MetaDoc>
        <ATTRIBUTES>
            <author>asas</author>
            <max_versions>1</max_versions>
            <summary>aasasqqqq</summary>
        </ATTRIBUTES>
    </MetaDoc>
</Document>

© Stack Overflow or respective owner

Related posts about c#