is there an easy way to map values of a dictionary with a xml file? I have a XML template and need to map all values of the dict to the xml. The dict keys are the text element in the xml file.
dict = { country1_rank : 1, country1_year : 2008, country1_gdppc : 141100, country2_rank : 4, country2_year : 2011, country2_gdppc : 59900, country3_rank : 69, country3_year : 2011, country3_gdppc : 13600 }
<?xml version="1.0"?>
<data>
<country1>
<rank>country1_rank</rank>
<year>country1_year</year>
<gdppc>country1_gdppc</gdppc>
</country1>
<country2>
<rank>country2_rank</rank>
<year>country2_year</year>
<gdppc>country2_gdppc</gdppc>
</country2>
<country3>
<rank>country3_rank</rank>
<year>country3_year</year>
<gdppc>country3_gdppc</gdppc>
</country3>
</data>
In the end the output should look like this:
<?xml version="1.0"?>
<data>
<country1>
<rank>1</rank>
<year>2008</year>
<gdppc>141100</gdppc>
</country1>
<country2>
<rank>4</rank>
<year>2011</year>
<gdppc>59900</gdppc>
</country2>
<country3>
<rank>69</rank>
<year>2011</year>
<gdppc>13600</gdppc>
</country3>
</data>