我希望将其作为XML:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:sear="http://eur-lex.europa.eu/search">
<soap:Header>
</soap:Header>
</soap:Envelope>
我的代码:
Dim D As New Xml.XmlDocument
Dim soapEnvelope As Xml.XmlElement = D.AppendChild(D.CreateElement("soap", "Envelope", "http://www.w3.org/2003/05/soap-envelope"))
soapEnvelope.SetAttribute("xmlns:sear", "http://eur-lex.europa.eu/search")
Dim soapHeader As Xml.XmlElement = soapEnvelope.AppendChild(D.CreateElement("soap:Header"))
但是Header Element没有“soap”前缀。
不是:
<soap:Header>
我该如何解决?
答案 0 :(得分:0)
不是创建名为soap:Header
的元素,而是执行此操作:
Dim soapHeader As Xml.XmlElement =
soapEnvelope.AppendChild(
D.CreateElement("soap", "Header", "http://www.w3.org/2003/05/soap-envelope"))
您也可以使用XNamespace
解释in the documentation,甚至可以使用Xml文字。