Reputation: 724
I have a java application which asks questions and the user answers either with "yes" or "No".
What I want is that at the end of all questions I get a xml document with questions and its answers.
So when one of the questions is "Are you male?" and the answer is "yes" so the xml file should be:
<?xml ....>
...
<question>Are you male?</question>
<answer>yes</answer>
...
/>
How can I do that? Thanks
Upvotes: 0
Views: 102
Reputation: 121
Here is an example of implementing this using the Parser, the link shows the basic method of creating an XML through Java, you can put some conditions and adjust the code. here is the link on how to create xml file in java Hope it helps
Upvotes: 1
Reputation: 1155
You can use JAXB to annotate a set of classes which represent the questions or you can manually generate the XML using an OutputStream to a file. I would suggest using JAXB.
Upvotes: 4