给定以下 C# 代码来生成 XML 文件:
XmlDocument requestXML = new XmlDocument();
XmlDeclaration declaration = requestXML.CreateXmlDeclaration( "1.0", "utf-8", null );
requestXML.AppendChild( declaration );
XmlElement soapEnvelope = requestXML.CreateElement( "soap:Envelope" );
soapEnvelope.SetAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
soapEnvelope.SetAttribute( "xmlns:xsd", "http://www.w3.org/2001/XMLSchema" );
soapEnvelope.SetAttribute( "xmlns:soap", "http://schemas.xmlsoap.org/soap/envelope/" );
我在requestXML.OuterXML
节目中看到的 XML
<Envelope ...>
而不是
<soap:Envelope ...>
正如我所料。我究竟做错了什么?