0
我想知道如何以简单的方式将结构化的python列表转换为xml并将其存储为xml文件? 我可以跳过线,或与“无”里面:如何将结构化的python列表转换为xml
[ ['None', None, None, None, None, None, 'False', 'None', 'None'],
...
['None', None, None, None, None, None, 'False', 'None', 'None']
]
这是我的结构化列表看起来像:
[ [ 'This is the first case',
'CASE001',
'Linux',
'2017-08-18 06:45:58',
'2017-08-18 06:46:47',
'55',
'Pass',
[],
[ ['None', None, None, None, None, None, 'False', 'None', 'None'],
...
['None', None, None, None, None, None, 'False', 'None', 'None']
]
],
[ 'This is the second case',
'CASE002',
'Linux',
'2017-08-18 07:45:58',
'2017-08-18 07:46:47',
'65',
'Pass',
[],
[ ['None', None, None, None, None, None, 'False', 'None', 'None'],
...
['None', None, None, None, None, None, 'False', 'None', 'None']
]
],
...
]
的XML我不需要所有的字段,但我不介意是否更容易解析所有领域!最进口是获得一个XML文件,它应该是这样的:
<case>
<header>This is the first case</header>
<name>CASE001</name>
<age>Linux</age>
<failedSince>0</failedSince>
<skipped>false</skipped>
<duration>55</duration>
<status>PASSED</status>
</case>
...
我建议你使用XML库(例如作为['etree'](https://docs.python.org/3/library/xml.etree.elementtree.html)包含在Python中)。如果遇到问题,请提供一个[最小,完整且可验证的示例](https://stackoverflow.com/help/mcve) ,它重现您的问题并请求更具体的问题。 –
谢谢,我找到了一个可行的解决方案,并会回答我的问题,以供所有其他人使用! – FotisK