Writing a custom XML file for the Wordpress Importer using lxml

吃可爱长大的小学妹 提交于 2019-12-02 09:53:55

Here is my advice: Take a step back from lxml and consider the python built-in support for xml processing: a module called xml.etree.ElementTree. Import it in repl like this:

import xml.etree.ElementTree as ET

and play with it for a while. Here is a good python documentation on the module: http://goo.gl/8FVto

Building an element is as simple as that:

a = ET.Element('wp:author')
ET.dump(a)

Then add some sub-elements. It's all in the docs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!