Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用LINQ到XML构建SOAP信封_C#_Xml_Linq - Fatal编程技术网

C# 使用LINQ到XML构建SOAP信封

C# 使用LINQ到XML构建SOAP信封,c#,xml,linq,C#,Xml,Linq,我必须构造一个XML文档,它有一个SOAP信封,如下所示: <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body> 给出此错误: “:”字符(十六进制值0x3A)不能包含在 名字 有什么线索吗 提前谢谢。试试这个 XNamespace soap = "http://schemas.xmlsoap.org/soap/envelope/"

我必须构造一个XML文档,它有一个SOAP信封,如下所示:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Body>
给出此错误:

“:”字符(十六进制值0x3A)不能包含在 名字

有什么线索吗

提前谢谢。

试试这个

XNamespace soap = "http://schemas.xmlsoap.org/soap/envelope/";

XElement element = new XElement(soap + "Envelope", 
    new XAttribute(XNamespace.Xmlns + "SOAP-ENV", soap),
    new XElement(soap + "Body")); 
XNamespace soap = "http://schemas.xmlsoap.org/soap/envelope/";

XElement element = new XElement(soap + "Envelope", 
    new XAttribute(XNamespace.Xmlns + "SOAP-ENV", soap),
    new XElement(soap + "Body"));