我正在使用XmlWriter,我想知道是否有人曾尝试使用属性来编写xml元素字符串(叶节点),以使输出看起来像
<book id='1' author='j.k.rowling' year='2010'>999</book>
代替
<book id='1' author='j.k.rowling' year='2010'> <book>999</book> </book>
您可以使用
WriteString …
原文链接:https://www.f2er.com/xml/292802.htmlusing (XmlWriter writer = XmlWriter.Create("books.xml")) { writer.WriteStartElement("book"); writer.WriteAttributeString("author","j.k.rowling"); writer.WriteAttributeString("year","1990"); writer.WriteString("99"); writer.WriteEndElement(); }