替换双引号 .将字符串“
本文关键字:xml 替换 字符串 | 更新日期: 2023-09-27 18:33:09
这是我通过代码创建的XML
文件。我想用空或空替换起始引号。
"<?xml version="1.0" encoding="utf-8"?>
您可以使用 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>