这是我通过代码创建的XML
文件。我想用空格或空格替换起始引号。
"<?xml version="1.0" encoding="utf-8"?>
答案 0 :(得分:0)
您可以使用XmlWriterSettings并将OmitXml声明设置为true:
XmlWriterSettings settings = new XmlWriterSettings ();
settings.Indent = true ;
settings.OmitXmlDeclaration = true ;
settings.NewLineOnAttributes = true ;
writer = XmlWriter.Create (Console.Out, settings);
writer.WriteStartElement ( "order" );
writer.WriteAttributeString ( "orderID" , "367A54" );
writer.WriteAttributeString ( "date" , "2001-05-03" );
writer.WriteElementString ( "price" , "19.95" );
writer.WriteEndElement ();
writer.Flush ();
将生成:
<order
orderID = "367A54"
date = "2001-05-03">
<price> 19.95 </price>
</order>