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 6868407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:25:51+00:00 2026-05-27T03:25:51+00:00

I have searched forever tryng to figure out what I am doing wrong in

  • 0

I have searched forever tryng to figure out what I am doing wrong in trying to deseralize some xml to a list. I am able to get the deserailzation of eveything but the answers, so the deserailization is working but it appears I am missing something on the class decorations. The answers show in the “testObj”, but are null.

Any help is appreciated.

Sample Xml

<?xml version="1.0" encoding="utf-8" ?>
<TestObj xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<question>
    <stem>this is the question stem</stem>
    <answers>
      <answer>answer 1</answer>
      <answer>answer 2</answer>
      <answer>answer 3</answer>
      <answer>answer 4</answer>
 </question>
 <question .... </question>
 <question .... </question>
 <question .... </question>
</TestObj>

[Serializable]
    public class TestObj
    {
        [XmlElement(ElementName = "question")]
        [XmlElement(typeof(QuestionObj))]
        public List<QuestionObj> Questions { get; set; }

        public int Id { get; set; }
        public string Name;
    }

[Serializable]
    public class QuestionObj
    {
        [XmlElement(ElementName = "stem")]
        public string Stem { get; set; }


        [XmlArray("answers")]
        [XmlArrayItem(ElementName = "answer")]
        [XmlArrayItem(typeof(AnswerObj))]
        public List<AnswerObj> Answers { get; set; }

        public int TestId { get; set; }
        public int Id { get; set; }
    }

[Serializable]
   public class AnswerObj
    {
        [XmlElement(ElementName = "answer")]
        public string Answer { get; set; }

       public int Id { get; set; }
       public int StemId { get; set; }
    }

Object returned:
Question:this is the question stem
   answers
      answer:null
      answer null;
etc
  • 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-27T03:25:51+00:00Added an answer on May 27, 2026 at 3:25 am

    Your serialization attributes are making the serializer look for an xml structure like this:

    <question>
      <answers>
        <answer>
          <answer>answer text</answer>
          <Id>1234</Id>
          <StemId>1234</StemId>
        </answer>
      </answers>
    </question>
    

    You can either change the serializer to use a List<string> for the answers or construct an AnswerObj in xml for each answer (as per above).

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

Sidebar

Related Questions

I have searched and read through the internet trying to figure out this problem.
(have searched, but not been able to find a simple solution to this one
I have searched for this, and I can't find any documentation about doing these
I have searched a lot about this topic and I can't get this code
I have searched for some answers but I cannot find anything. So how do
I have searched and searched and I cannot find a page which spells out
I have searched for some similar questions before posting - however I have a
I have searched and searched but as yet still cannot figure this ole problem
I am trying to figure out how to turn off the screen from within
Have searched on this issue and haven't been able to find a solution. I

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.