【发布时间】:2016-11-14 22:47:57
【问题描述】:
我需要创建一个具有这种结构的 XML:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:res="http://resource.webservice.correios.com.br/">
<soapenv:Header/>
<soapenv:Body>
<res:buscaEventos>
<usuario>ECT</usuario>
<senha>SRO</senha>
<tipo>L</tipo>
<resultado>T</resultado>
<lingua>101</lingua>
<objetos>JS331400752BR</objetos>
</res:buscaEventos>
</soapenv:Body>
</soapenv:Envelope>
但是这样就错了:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:res="http://resource.webservice.correios.com.br/">
<soapenv:Header />
<soapenv:Body>
<res:buscaEventos xmlns:res="http://schemas.xmlsoap.org/soap/envelope/">
<usuario>ETC</usuario>
<senha>SRO</senha>
<tipo>L</tipo>
<resultado>T</resultado>
<lingua>101</lingua>
<objetos>JS331400752BR</objetos>
</res:buscaEventos>
</soapenv:Body>
</soapenv:Envelope>
区别在于buscaEventos
我通过以下方式创建
XmlNode eventosNode = xmlDoc.CreateElement
( "res " , " buscaEventos " " http://schemas.xmlsoap.org/soap/envelope/ " ) ; 如何删除 xmlns : res only that node?
【问题讨论】:
-
来之前先google一下,你会得到答案的;有很多关于如何实现这一目标的博客文章和 SO 文章
标签: c# xml xmldocument