I'm trying to make a script (bash or python ideally, so I learn and don't just use it dumbly) that will parse a XML file that looks like this :
<?xml version="1.0" encoding="UTF-8"?>
<fruits xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://whatever/fruits.xsd" timestamp="1521126010" merchantId="xxxx">
<fruit id="1" name="Orange" color="orange"/>
<fruit id="2" name="Mandarine" color="Orange"/>
<fruit id="3" name="Raisin" color="Green" variety="4"/>
<fruit id="4" name="Raspberrry" color="red" variety="2"/>
<fruit id="5" name="Kiwi" color="brown"/>
<fruit id="6" name="I am a fruit" variety="7">
</fruits>
I'm trying to make a script that can return me the differents attributes. For example :
./script Raisin -c
Orange
./script Kiwi -v
No variety defined
./script "I am a fruit" -i
6
And so on. I've read a lot on XML parsing, but didn't found anything yet with that kind of XML file. Any help would be greatly appreciated.
-ioption? Describe all your options