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

  • Home
  • SEARCH
  • 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 8716335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:03:18+00:00 2026-06-13T06:03:18+00:00

I have the following xml file: <ArrayOfX xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema> <X> <Name>Name1</Name> <ArrayOfY> <Y> <Member1>1</Member1>

  • 0

I have the following xml file:

<ArrayOfX xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <X>
    <Name>Name1</Name>
    <ArrayOfY>
      <Y>
        <Member1>1</Member1>
      </Y>
      ...
    </ArrayOfY>
  </X>
  ...
</ArrayOfX>

public class X {
    public string Name { get; set; }
    public List<Y> Y { get; set; }
}

public class Y {
    public String Member1 { get; set; }
}

But if i try to deserialize with XmlSerializer, Name contains the correct value but the Y list is empty. Any idea?

XmlSerializer serializer = new XmlSerializer( typeof( List<X> ) );
return (List<X>)serializer.Deserialize(reader);
  • 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-06-13T06:03:19+00:00Added an answer on June 13, 2026 at 6:03 am

    Try this:

    public class X {
        public string Name { get; set; }
        [XmlArray(ElementName = "ArrayOfY")]
        public List<Y> Y { get; set; }
    }
    

    With you class definition, if you try to serialize of a List<X>, the output would looks like:

    <ArrayOfX xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <X>
        <Name>Name1</Name>
        <Y> <!-- Not ArrayOfY -->
          <Y>
            <Member1>1</Member1>
          </Y>
          ...
        </Y>
      </X>
      ...
    </ArrayOfX>
    

    Your provided xml file is not a valid format to the XmlSerializer(typeof(List<X>)). It’s expecting <Y> instead of <ArrayOfY> for the List<Y> member of X.

    The attribute I added would instruct the serializer to look for an element with name ArrayOfY instead.

    • 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 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 XSD file: <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://www.wvf.com/schemas' xmlns='http://www.wvf.com/schemas' xmlns:acmewvf='http://www.wvf.com/schemas'> <xs:element name='loft'> </xs:element>
Lets say I have the following XML file: <?xml version=1.0 encoding=utf-8?> <Customers xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation=Customer.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 following XML file: <?xml version=1.0 encoding=UTF-8?> <beans xmlns=http://www.springframework.org/schema/beans xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:jaxrs=http://cxf.apache.org/jaxrs xmlns:context=http://www.springframework.org/schema/context xmlns:cxf=http://cxf.apache.org/core
I have following xml: <xs:schema attributeFormDefault=unqualified elementFormDefault=qualified xmlns=http://www.testuri.org targetNamespace=http://www.testuri.org xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:element name=Price> <xs:complexType> <xs:sequence>
I have the following xml file <kml xmlns=http://www.opengis.net/kml/2.2 xmlns:gx=http://www.google.com/kml/ext/2.2 xmlns:kml=http://www.opengis.net/kml/2.2 xmlns:atom=http://www.w3.org/2005/Atom> <Placemark> <name>Simple placemark</name>
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 following xml file as input .... <?xml version=1.0 encoding=ISO-8859-1?> <T0020 xsi:schemaLocation=http://www.safersys.org/namespaces/T0020V1 T0020V1.xsd
I have the following XML layout file, HELPME.XML <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent

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.