从工厂创建的对象python suds中删除元素

时间:2014-11-12 22:29:39

标签: python xml soap suds

我想知道如何删除插入到请求中的元素。

from suds.client import Client

client = Client('http://localhost/Service?wsdl')

lookup = client.factory.create('ns3:retreive')
lookup.person = 'Dave'

这是肥皂水所产生的。

<body>
  <retrieve>
    <random>
      <person>Dave</person>
    </random>
  </retrieve>
<body>

我将如何删除随机元素?

1 个答案:

答案 0 :(得分:-1)

以下是我如何从请求中删除元素(在本例中为entityType)的示例:

    # Remove entityType from the search input if it is None.  This is 
    # because if it is None, suds will insert an empty element 
    # (<entityType/>) into the request, which the server doesn't like.
    if searchInput.entityType.value == None:
        del searchInput.entityType