Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.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# 正在将Xml转换为字符串。是否为每个标记添加新行?_C#_Xmldocument - Fatal编程技术网

C# 正在将Xml转换为字符串。是否为每个标记添加新行?

C# 正在将Xml转换为字符串。是否为每个标记添加新行?,c#,xmldocument,C#,Xmldocument,我正在通过代码创建XmlDocument,并添加一些标记。结构是这样的 <root> <test> <test1>a</test1> </test> <test> </test> <test> <test1b</test1> </test> </root> 但是当我检查生成的字符串时,所有标记都在同一行上。 有没有办法告诉它每行只导出

我正在通过代码创建
XmlDocument
,并添加一些标记。结构是这样的

<root>
 <test>
  <test1>a</test1>
 </test>
 <test>
 </test>
  <test>
  <test1b</test1>
 </test>
</root> 
但是当我检查生成的字符串时,所有标记都在同一行上。 有没有办法告诉它每行只导出一个标记

XmlTextWriter xmlTextWriter = new XmlTextWriter("file.xml",null);    
xmlTextWriter.Formatting = Formatting.Indented;
XmlTextWriter xmlTextWriter = new XmlTextWriter("file.xml",null);    
xmlTextWriter.Formatting = Formatting.Indented;