Given the following C# code to generate an XML file:
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.SetAttribut开发者_如何学JAVAe( "xmlns:soap", "http://schemas.xmlsoap.org/soap/envelope/" );
The XML I'm seeing in requestXML.OuterXML
shows
<Envelope ...>
Rather than
<soap:Envelope ...>
as I would expect. What am I doing wrong?
Maybe you could try the CreateElement
overload that takes a namespace uri as parameter #2.
精彩评论