Hi everyone!
I have a doubt about reading records in a XML file. For example, I have a xml file where it's stored a menu which describes what will be served each day. So, I would like to creat a Bash or Python script for getting information about this xml file.
XML example:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<restaurant>
<monday>
<date>
23/06/2008</date>
<lunch>
<salad>
There is no salad.</salad>
<main>
Beef with four cheese</main>
<extras>
Chocolate</extras>
<dessert>
Chocolate</dessert>
</lunch>
<dinner>
<salad>
There is no salad.</salad>
<main>
Chicken</main>
<extras>
Apple</extras>
<dessert>
Apple</dessert>
</dinner>
</monday>
<tuesday>
<date>
24/06/2008</date>
<lunch>
<salad>
There is no salad.</salad>
<main>
Beef</main>
<extras>
Orange</extras>
<dessert>
Orange</dessert>
</lunch>
<dinner>
<salad>
There is no salad.</salad>
<main>
Beef</main>
<extras>
Yogurte</extras>
<dessert>
Yogurte</dessert>
</dinner>
</tuesday>
<wednesday>
<date>
25/06/2008</date>
<lunch>
<salad>
There is no salad.</salad>
<main>
Fish</main>
<extras>
Pineapple</extras>
<dessert>
Pineapple</dessert>
</lunch>
<dinner>
<salad>
There is no salad.</salad>
<main>
Chicken</main>
<extras>
Chocolate</extras>
<dessert>
Chocolate</dessert>
</dinner>
</wednesday>
<thursday>
<date>
26/06/2008</date>
<lunch>
<salad>
There is no salad.</salad>
<main>
Feijoada completa</main>
<extras>
Laranja</extras>
<dessert>
Laranja</dessert>
</lunch>
<dinner>
<salad>
There is no salad.</salad>
<main>
Bife acebolado</main>
<extras>
Mamão</extras>
<dessert>
Mamão</dessert>
</dinner>
</thursday>
<friday>
<date>
27/06/2008</date>
<lunch>
<salad>
There is no salad.</salad>
<main>
Chicken</main>
<extras>
Yogurte</extras>
<dessert>
Yogurte</dessert>
</lunch>
<dinner>
<salad>
There is no salad.</salad>
<main>
Hamburger</main>
<extras>
Banana</extras>
<dessert>
Banana</dessert>
</dinner>
</friday>
<saturday>
<date>
28/06/2008</date>
<lunch>
<salad>
There is no salad.</salad>
<main>
Vegetables</main>
<extras>
Chocolate</extras>
<dessert>
Chocolate</dessert>
</lunch>
<dinner>
<empty />
</dinner>
</saturday>
</restaurant>
Now, let's say I would like to know what will be served on saturday. I would get this by using:
Code:
$ menu.university saturday
Or, I would like to know what will be served for lunch on monday. I would get this by using:
Code:
$ menu.university monday lunch
Does anybody have any insight for helping me coding this?
Thanks in advance.
[]s