开发者

Generating Python code from XML tree

What is the best way in P开发者_StackOverflowython to read XML from a file, build a tree, do some rewriting in the tree and generate Python code? (I'm slightly confused as in Python there seem to be multiple options such as expat, ElementTree, XSLT, ...).


You should check out lxml. It is easy to use and does what you want in a few steps. If you want to stick to the stdlib, then you check out ElementTree (Python 2.5+) . The type of XML processing you want depends on your needs and for high performance XML parsing, read this.

EDIT: My answer is for XML parsing with Python and does not answer your last question: "generate Python code", cause that makes no sense :)


I use Beautiful Soup. Its relatively easy to use and powerful. Check it out here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜