简体   繁体   English

有没有办法将XML转换成字典和列表?

[英]Is there a way to turn XML into dictionary and lists?

<things>
    <fruit>apple</fruit>
    <hardware>mouse</hardware>
...
</things>

Turn it into: 变成:

{'things':[{'fruit':'apple'}, {'hardware':'mouse'}]}

Is there an easy way to do this? 是否有捷径可寻? Thanks. 谢谢。

there's a nice recipe for that here: 这里有一个很好的食谱:

http://code.activestate.com/recipes/570085/ http://code.activestate.com/recipes/570085/

another good one is here: 另一个好人在这里:

http://code.activestate.com/recipes/522991/ http://code.activestate.com/recipes/522991/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM