Creating a voting system
We will create an example where users will be able to vote for their favorite browsers. Once voted, they will not be able to vote for another day, that is 24 hours. Votes will be stored in an XML file. We will also display the votes in a nice graphical format.
Note
XML file has been used just for the example. In real world applications, data will be loaded from databases or web services (which can return anything like XML, JSON, or any other format).
Getting ready
Create a folder named Recipe8
inside the Chapter5
directory.
How to do it...
OK. This recipe is going to be a bit long, so grab a mug of coffee and start. First of all, create an XML file in the
Recipe8
folder and name it asbrowsers.xml
. This file will have information about the browsers that we will display to the user.<?xml version="1.0"?> <browsers> <browser name="Firefox" value="FF" votes="200"/> <browser name="Google Chrome" value="GC" votes="130"/> <browser name="IE" value...