我有以下字符串:
"Sweden, Västmanland, Västerås"
"Sweden, Dalarna, Leksand"
"Ireland, Cork, Cobh"
"Ireland, Clare, Boston"
"Ireland, Cork, Baltimore"
"Sweden, Dalarna, Mora"
我希望将其转换为 xml,如下所示:
<?xml version="1.0" ?>
<data>
<country name = "Ireland">
<region name = "Clare">
<settlement name = "Boston"/>
</region>
<region name = "Cork">
<settlement name = "Baltimore"/>
<settlement name = "Cobh"/>
</region>
</country>
<country name = "Sweden">
<region name = "Dalarna">
<settlement name = "Leksand"/>
<settlement name = "Mora"/>
</region>
<region name = "Västmanland">
<settlement name = "Västerås"/>
</region>
</country>
</data>
python3 的内置库可能会帮助我进行这种转换,以便我不必要地重新发明轮子?