Suds generates empty elements; how to remove them?

前端 未结 7 1632
傲寒
傲寒 2020-12-31 07:51

[Major Edit based on experience since 1st post two days ago.]

I am building a Python SOAP/XML script using Suds, but am struggling to get the code to generate SOAP/X

7条回答
  •  一向
    一向 (楼主)
    2020-12-31 08:54

    You can filter the empty elements out with a regular expression.

    Assuming your XML data is in the string xmltext;

    import re
    filteredtext = re.sub('\s+<.*?/>', '', xmltext)
    

提交回复
热议问题