Click here to Skip to main content
12,354,349 members (72,654 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
how can i design a multiple choice such all the questions and the answers to the questions in an xml file,using c#.please help me out.thanks in anticipation
Posted 28-Aug-12 6:28am
Edited 28-Aug-12 6:55am
Wes Aday 28-Aug-12 12:34pm
You write your XML in XML no C# involved. Perhaps you can clarify what it is that you are trying to do so that it makes sense.
ridoy 28-Aug-12 12:50pm
please clear your you want to design your work that will need C#?
Sourav Sarkar-SS 28-Aug-12 12:51pm
Where you kept your questions, in database or else?
Explain your question properly.
Your requirement is not proper
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

a) You do realize that tutors read these to see who can't do their assignments?
b) we don't do homework.
c) read this[^].
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

We can not give you the code here. You can still google to see if you can find similar example

But here is the pseudo code, go through it, you will find all the clues behind
1. Load the xml to XmlDocument. (namespace System.XML)
2. Parse the XML and get the answers in a IList or array string
3. Do a while loop on the collection object
4. Get each answer
5. Create a radio button dynamically and name it as radio_[counter] like radio_1, radio_2. This last number will be used to identify the answer when user checks a radio.
6. beside the radio, display the answer in a label.
7. There will be a button at the footer. Clicking the button will make a loop on radiobutton collection using forms.control
8. Get the checked radio button, parse the name of the radio button and get the last number.
9. Send the number to the database to get the answer. If matches, say "Right Answer", if no "Wrong Answer".

Try it yourself.
Best of luck.

Temidjoy 28-Aug-12 14:05pm
am i going to include the correct anwser,wrongs options and the question as an element in the xml for each questions available in the xml
Sandip.Nascar 28-Aug-12 14:21pm
Here is one sample xml which contains question, answers and right answer

Here flag represent the correct or incorrect answer.
Flag=1 is correct
Flag=0 is incorrect

Hope this helps.
Sandip.Nascar 28-Aug-12 14:21pm

Sandip.Nascar 28-Aug-12 14:25pm
sorry, somehow the xml is not allowed in comments. Som the blank lines... check in the solution section.
Sandip.Nascar 28-Aug-12 14:32pm
I don't know who is the guy downvoted the solution. Can you please come here and give the reason. If you have better solution, post your solution instead don't make nuisance of your power of voting.
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

As per your comments on xml, I tried to post the xml in comment.
Somehow the xml is not considered as valid text (probably due to security).

So, here is the sample xml with question, answer and correct flag.

<question id="1" description="What is the capital city of India?">
<answer id="1" description="Mumbai" flag="0" />
<answer id="2" description="Kolkata" flag="0" />
<answer id="3" description="New Delhi" flag="1" />
<answer id="4" description="Chennai" flag="0" />
<question id="1" description="XML can be parse using?">
<answer id="1" description="xmlparse" flag="0" />
<answer id="2" description="XmlDoc" flag="0" />
<answer id="3" description="XMLGrabber" flag="0" />
<answer id="4" description="XMLDocument" flag="1" />

Flag=1 is correct answer
Flag=0 is incorrect answer

Marcus Kramer 28-Aug-12 15:45pm
Please don't do people's homework for them. We want to help when they have issues, but providing something they can copy/paste as their own will teach them nothing.
Temidjoy 29-Aug-12 3:22am
thanks 4 d idea

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.160621.1 | Last Updated 28 Aug 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100