往返于Python字典的XML [英] XML to/from a Python dictionary

查看:114
本文介绍了往返于Python字典的XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用Python 2.4.4在XML字典之间来回转换XML.我需要的只是节点名称和值,我不用担心属性,因为我正在解析的XML没有任何属性.我不能使用ElementTree,因为它不适用于2.4.4,并且由于我的工作环境,我不能使用第三方库.对我来说,最简单的方法是什么?有什么好的摘要吗?

I need to use Python 2.4.4 to convert XML to and from a Python dictionary. All I need are the node names and values, I'm not worried about attributes because the XML I'm parsing doesn't have any. I can't use ElementTree because that isn't available for 2.4.4, and I can't use 3rd party libraries due to my work environment. What's the easiest way for me to do this? Are there any good snippets?

此外,如果没有简便的方法来执行此操作,那么Python 2.4.4是否有本机支持的替代序列化格式?

Also, if there isn't an easy way to do this, are there any alternative serialization formats that Python 2.4.4 has native support for?

推荐答案

问题将Python字典序列化为XML 列出了XML序列化的一些方法.至于其他序列化格式,我猜 pickle 模块是一个不错的工具

Question Serialize Python dictionary to XML lists some ways of XML serialization. As for alternative serialization formats, I guess pickle module is a nice tool for it.

这篇关于往返于Python字典的XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆