-1
我试图使用Excel表中的数据创建XML SOAP请求。目前,我已经使用了mako模板,但它需要XML模板。如何创建类似下面的命名空间的要求(这只是一个小样本不是完整的XML):如何使用Python ElementTree,LXML或类似的库创建肥皂请求
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mes="http://www.orange.com/Webalc/Interfaces/ManageSupplierQuote/RequestForQuotation/v3/message">
<soapenv:Header/>
<soapenv:Body>
<mes:CalculateSupplierQuote>
<!--1 to 500 repetitions:-->
<SupplierQuote>
<local_circuittype>Existing circuit</local_circuittype>
<local_businessOpportunity>Access to Orange Business Services Network</local_businessOpportunity>
<local_accessType>Upgrade/downgrade of full path diversity</local_accessType>
<!--Optional:-->
<local_configurationSite>single</local_configurationSite>
通过使用lxml的图书馆,我能够取得一些进展,但后来我卡住了。以下是我创建的代码。
from lxml import etree
import lxml.etree
import lxml.builder
Envelope = etree.Element("{http://www.w3.org/1999/soapenv}xmlns")
body = etree.SubElement(Envelope, "{http://www.w3.org/1999/soapenv}body")
print(etree.tostring(Envelope, pretty_print=True))
你尝试过这么远吗?发布你的代码和它输出的内容。 此外,您发布的XML无效,请发布完整文件。 –
嗨@PabloArias,我编辑了我的问题。在我开始研究mako模板之后,我上周做了这段代码。 –