Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5839101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:32:25+00:00 2026-05-22T11:32:25+00:00

I have the following xml file: <SOAP-ENV:Envelope xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/> <SOAP-ENV:Header xmlns:hdr=http://xml.example.com/ns/appmw/soap/1.0/header> <hdr:FinalMessage>true</hdr:FinalMessage> </SOAP-ENV:Header> <SOAP-ENV:Body> <MyResponse>

  • 0

I have the following xml file:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header xmlns:hdr="http://xml.example.com/ns/appmw/soap/1.0/header">
    <hdr:FinalMessage>true</hdr:FinalMessage>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <MyResponse>
      <Result seqNo="0">
        <MetaData>
          <DataSchema>
            <ColumnSchema type="char" ref="item1" name="Item1"/>
            <ColumnSchema type="char" ref="item2" name="Item2"/>
            <ColumnSchema type="char" ref="item3" name="Item3"/>
          </DataSchema>
        </MetaData>
        <Data>
          <Item>
            <Column ref="item1">Foo</Column>
            <Column ref="item2">Bar</Column>
            <Column ref="item3">Baz</Column>
          </Item>
          <Item>
            <Column ref="item1">Foo</Column>
            <Column ref="item2">Bar</Column>
            <Column ref="item3">Baz</Column>
          </Item>
        </Data>
      </Result>
    </MyResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Using xsd, I generated xsd files and then a C# class from those files. It works and the deserialization is fine, but the Data part class that was generated is not what I expected.

Here is the relevant xsd section:

      <xs:element name="Data" minOccurs="0" maxOccurs="1">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Item" minOccurs="0" maxOccurs="unbounded">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="Column" nillable="true" minOccurs="0" maxOccurs="unbounded">
                    <xs:complexType>
                      <xs:simpleContent msdata:ColumnName="Column_Text" msdata:Ordinal="1">
                        <xs:extension base="xs:string">
                          <xs:attribute name="ref" form="unqualified" type="xs:string" />
                        </xs:extension>
                      </xs:simpleContent>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>

There will be a single Data section that can have a variable number of Items. Each Item can have a variable number of Columns.

Here is what was generated for the class:

private MyResponseResultItemColumn[][] dataField;

    [System.Xml.Serialization.XmlArrayItemAttribute("Item", IsNullable=false)]
    [System.Xml.Serialization.XmlArrayItemAttribute("Column", NestingLevel=1)]
    public MyResponseResultItemColumn[][] Data {
        get {
            return this.dataField;
        }
        set {
            this.dataField = value;
        }
    }


[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class MyResponseResultItemColumn {

    private string refField;

    private string valueField;

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string @ref {
        get {
            return this.refField;
        }
        set {
            this.refField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlTextAttribute()]
    public string Value {
        get {
            return this.valueField;
        }
        set {
            this.valueField = value;
        }
    }
}

As you can see, xsd made Data an array of arrays (array of ItemColumn arrays). What I was expecting and want to see is Data as simple array of an Item class, where the Item class contains an array of ItemColumns as a property.

Is there a way I can achieve this? Instead of MyResponse.Result.Data[0][0] returning an array of ItemColumn, I want to be able to type MyResponse.Result.Data[0].ItemColumns.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T11:32:26+00:00Added an answer on May 22, 2026 at 11:32 am

    You can write your own serializer by implementing the IXmlSerializable interface. It’s a bit troublesome, but you have complete control over the shape of the object. This is a pretty good article on how to implement it, which I found in a thread on stackoverflow

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following xml; <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'> <env:Header> <mm7:TransactionID xmlns:mm7='http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-6-MM7-1-4' env:mustUnderstand='1'>6797324d</mm7:TransactionID> </env:Header> <env:Body> <DeliveryReportReq
I have created the following vsct file xml. <?xml version=1.0 encoding=utf-8?> <CommandTable xmlns=http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable xmlns:xs=http://www.w3.org/2001/XMLSchema>
I have the following xml file <Layout xmlns=http://tempuri.org/Layout/> <Numeric Id=temperature Caption=Temperature> <validation:IsValidWhen xmlns:validation=http://tempuri.org/Validation/> </validation:IsValidWhen>
I have an XML/Soap file that looks like this: <?xml version=1.0 encoding=utf-8?> <soap:Envelope xmlns:soap=http://www.w3.org/2003/05/soap-envelope
I have the following XML file: <?xml version=1.0 encoding=utf-8?> <SearchResults:searchresults xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://www.zillow.com/static/xsd/SearchResults.xsd /vstatic/279989c5e93d519f8d8f23d3f6cac661/static/xsd/SearchResults.xsd xmlns:SearchResults=http://www.zillow.com/static/xsd/SearchResults.xsd>
I have the following xml file <ScheduleProvider id=257 scheduleDate=2008-03-20T15:34:18Z xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation=my.xsd> <Content action=insert duration=7200
I have the following in an XML file: <entry> ... <link href=http://www.example.com/somelink /> ...
i have following xml file as input .... <?xml version=1.0 encoding=ISO-8859-1?> <T0020 xsi:schemaLocation=http://www.safersys.org/namespaces/T0020V1 T0020V1.xsd
For example I have file config.xml in that file I have following xml content
I have the following xml file: <xfa:data> <form1> <Page1> <Page2> <contractInfo> ... </contractInfo> <paymentInfo>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.