【发布时间】:2017-03-27 16:58:15
【问题描述】:
我必须创建一个包含命名空间的 SOAP 请求,文档应该如下所示,
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v1="http://bhargavsaidama.com/services/schema/mser/mlistr/v1"
xmlns:v11="http://bhargavsaidama.com/services/schema/gs/rblock/v1"
xmlns:v12="http://bhargavsaidama.com/services/schemas/ut/mi/v1">
<soapenv:Header>
</soapenv:Header>
<soapenv:Body>
<v1:MLreq>
<v11:IDB>
</v11:IDB>
</v1:Mlreq>
<v1:Rparams>
<v12:MsgL>32</v12:MsgL>
</v1:Rparams>
</soapenv:Body>
</soapenv:Envelope>
但我知道使用 xml.etree.ElementTree 中的根和元素方法创建一个没有命名空间的 xml 文档,而且我也知道从 xml 文档中解析数据通过使用 xpath 和 lxml 具有命名空间,但我无法理解如何创建像上面这样的文档.我试图找到教程,但在大多数地方都不清楚。有人能帮我理解一下吗?
谢谢
【问题讨论】: