This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Yes, using the SAX approach, you can write a program to read the XML file and store the data in a ListArray (or any other collection) of Card objects with the members you show. Using SAX, you write a class to process the data, and get called at three main methods -- startElement, endElement, and characters.
Why XML? In my opinion, on of the big reasons is that you can validate your input before you start. If you were to do a good job on the program above, you would have to worry about what happens if one card did not have a location, or if a card had two enghishwords. What if someone created a file with
There are lots of ways someone could create a such a file that could cause problems to your program. If you were to describe the proper content (using something called XML Schema) then the sender could check before sending to make sure the input was correct, and you could check before processing the file that it was "proper". You can specify the sequence of elements, how often they occur, and what kind of content is valid.
The difficulty between writing a commercial-grade program to read an unvalidated file vs. a validated one is very large. To process a validated file, the job is much easier.
Is XML the answer to all data interchange problems? No. Can it be force fit into situations for which it is a lousy answer? Of course. Like all technologies, it needs to be used in the right places and avoided in the wrong places.