0
<Question>
<Questions ID="1">
<English> What is water in French? </English>
<Answer> Eau </Answer>
</Questions>
</Question>

I have the above XML file for example (question.xml), and I'll like to print the contents in "English" then request user input, then compare that to the "Answer". How do I do that in Java

2
  • 1
    docs.oracle.com/javase/tutorial/jaxp/sax/index.html Commented Feb 26, 2015 at 20:15
  • Raul's response is correct. You could parse the XML, store the values in a DB or in memory and write a servlet and some logic to compare the user's response to what you have in the database. It's a little bit of work, but not terribly complicated. Probably a decent first project in Java. Commented Feb 26, 2015 at 20:26

2 Answers 2

1

The easy way could be to read all your XML and store your English and Answer values, after parsing, you can request user input.

If you want to request input as you parse, you could write a multi-threaded program, in which one thread parses the XML and the other requests user input, synchronizing both threads with locks, however this would be difficult to implement and risky to detect and catch bugs...

Sign up to request clarification or add additional context in comments.

Comments

1

There are several java api for XML Parsing

In your case DOM parser is best. Use DOM parser link to quick guide to learn

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.