JohnAutoSales
asked on
Getting data from a tuple
Hi there,
I've got a tuple of the following form:
factoryloc = (make , country).
But there are many members in the tuple, i.e.:
factoryloc = ((toyota , japan) , (fiat , italy) , ...... )
I then have an XML file like this:
<garage name="wood road">
<vehicle make="toyota" model="yaris">
<note>
New model - 1 litre Terra
</note>
</vehicle>
<vehicle make="nissan" model="note">
<note>
Second hand - red, 15000 miles
</note>
</vehicle>
...
</garage>
I need to get the make of each vehicle from the XML file, and then find the corresponding country from the reference tuple in Python, and store the relevant country so that I can use it again later on.
I realise that I could have just added an extra attribute in the XML file called country, but the XML structure that we now use is well established.
Help would be greatly appreciated,
Thanks,
John
I've got a tuple of the following form:
factoryloc = (make , country).
But there are many members in the tuple, i.e.:
factoryloc = ((toyota , japan) , (fiat , italy) , ...... )
I then have an XML file like this:
<garage name="wood road">
<vehicle make="toyota" model="yaris">
<note>
New model - 1 litre Terra
</note>
</vehicle>
<vehicle make="nissan" model="note">
<note>
Second hand - red, 15000 miles
</note>
</vehicle>
...
</garage>
I need to get the make of each vehicle from the XML file, and then find the corresponding country from the reference tuple in Python, and store the relevant country so that I can use it again later on.
I realise that I could have just added an extra attribute in the XML file called country, but the XML structure that we now use is well established.
Help would be greatly appreciated,
Thanks,
John
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
1 - how do I get the make from tthe XML?
2 - how do I look it up in a tuple of tuples?
3 - how do I store it for later use? (What is your definition of later - during this program execution, or running another program later)?
Why are you storing the factoryloc in tuples? A dictionary would be a lot easier to use.