Close a tag with no text in lxml

前端 未结 4 1941
[愿得一人]
[愿得一人] 2020-12-11 21:36

I am trying to output a XML file using Python and lxml

However, I notice one thing that if a tag has no text, it does not close itself. An example of this would be:<

4条回答
  •  盖世英雄少女心
    2020-12-11 22:04

    Note that and mean exactly the same thing. What you want is for the test-tag to actually do have a text that consists in a single linebreak. However, an empty tag with no text is usually written as and it makes very little sense to insist on it to appear as .

提交回复
热议问题