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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:35:29+00:00 2026-06-15T19:35:29+00:00

how do i parse this xml data’s Question element into an object called question

  • 0

how do i parse this xml data’s “Question” element into an object called “question” with a string array property called “options”? I know there are lots of xml posts with answers but they all confuse me i just need one that fits my problem. There will be a total of 50 questions in the xml file, and i want to extract each question element and it’s child elements and contents into a question object. i use c# on visual studio 2010.

<?xml version="1.0" encoding="utf-8" ?>
<Questions>
 <Question id ="1">
<Content>Which of the following statements represents the view expressed by the writer    in the first paragraph?</Content>
<Options>
  <A>Evil Thoughts will eventually ruin the evil man.</A>
  <B>If we do not stop the pendulum of thoughts from swinging, our thoughts will soon become our enemies.</B>
  <C>Too many evil thoughts leave fatal consequence.</C>
  <D>It is possible to decide what controls our thoughts.</D>
</Options>
</Question>
<Question id ="2">
<Content>From the argument in the second paragraph, it can be concluded that evil thoughts control the lives people who</Content>
<Options>
  <A>are helpless because they fly out of their minds</A>
  <B>cherish idle and slothful ways</B>
  <C>are thieves with evil instincts</C>
  <D>treasure and ruminate on them.</D>
</Options>
</Question>
<Question id ="3">
   <Content>The expression think of the devil and he will appear..., as used in this  passage, suggests that</Content>
 <Options>
  <A>like the devil, evil thoughts must not reign in our hearts</A>
  <B>evil thoughts are fantasies which exist only in people's minds</B>
  <C>uncontrolled evil thoughts may lead to evil deeds</C>
  <D>the devil gives evil thoughts only to those who invite him in.</D>
</Options>
</Question>
<Question id ="4">
<Content>Which of the following statements summarizes the argument of the last paragraph?</Content>
 <Options>
  <A>Heavy traffic on a miry and dirty road may lead to evil thoughts.</A>
  <B>The more evil we think, the more vile we are likely to become.</B>
  <C>Evil people should not be welcomed as guest in our homes the same way as we welcome good people.</C>
  <D>Evil thoughts control the key to the human heart and no one can keep the out.</D>
</Options>

  • 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-15T19:35:30+00:00Added an answer on June 15, 2026 at 7:35 pm

    You can do that with LINQ to Xml:

    XDocument xdoc = XDocument.Load(path_to_xml);
    var query = xdoc.Descendants("Question")
                    .Select(q => new Question()
                    {
                        Id = (int)q.Attribute("id"),
                        Content = (string)q.Element("Content"),
                        Options = q.Element("Options")
                                   .Elements()
                                   .Select(o => (string)o).ToArray()
                    });
    

    This will return IEnumerable<Question> sequence, where Question is a class like:

    public class Question
    {
        public int Id { get; set; }
        public string Content { get; set; }
        public string[] Options { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can some one guide me how to parse this Xml type string ? <data>
I would like to parse this xml file: <?xml version=1.0 encoding=utf-8?> <resources> <string-array name=descripciones>
I am currently trying to parse some xml data into an NSDictionary . This
I'm trying to parse this XML string: <?xml version=1.0 encoding=UTF-8 standalone=no?> <response type=success> <lots>
I am stuck in how to parse this kind of XML (with same element
Hello all I'm using NSXMLParser to parse some xml data. I'm using this data
I'm using PHP xmlreader to validate and parse xml data. This xml is validated
How can i parse this XML with C# WP7 to different lists for binding
I'm trying to parse this XML I want to get a list of all
I'm try to parse this xml, but c# keeps throwing an exception saying it

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.