Writing a custom XML file for the Wordpress Importer using lxml

后端 未结 1 1857
我寻月下人不归
我寻月下人不归 2021-01-28 00:52

Okay, so here is my current situation:

My knowledge of XML or lxml isn\'t very good yet, since I rarely used XML files until now. So please tell me if something in my ap

相关标签:
1条回答
  • 2021-01-28 01:13

    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.

    0 讨论(0)
提交回复
热议问题