Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.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# 无效的XMlRoot元素_C#_Xml - Fatal编程技术网

C# 无效的XMlRoot元素

C# 无效的XMlRoot元素,c#,xml,C#,Xml,我的xml输出应该是这样的 <ns1:customerApplication soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:"> <ns_x003A_CustomerApplication xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" </ns_x003A__

我的xml输出应该是这样的

<ns1:customerApplication
     soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
     xmlns:ns1="urn:">
  <ns_x003A_CustomerApplication xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    </ns_x003A__CustomerApplication>
但我越来越像这样了

<ns1:customerApplication
     soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
     xmlns:ns1="urn:">
  <ns_x003A_CustomerApplication xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    </ns_x003A__CustomerApplication>

您只指定了元素名,因此它必须转义“:”到被接受为元素名的东西-x003A(十六进制编码的“:”)

您需要指定命名空间和节点名称,如中所示

xml元素名称的“ns1”部分实际上是一个xml名称空间限定符,它是实际名称空间的快捷方式。你能告诉我们名称空间是什么吗?它应该位于CustomerApplication元素所在位置的父元素之一中。它通常看起来像