XmlWriter将元素字符串写入属性

我正在使用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
using (XmlWriter writer = XmlWriter.Create("books.xml"))
{

    writer.WriteStartElement("book"); 
    writer.WriteAttributeString("author","j.k.rowling"); 
    writer.WriteAttributeString("year","1990");
    writer.WriteString("99");
    writer.WriteEndElement();                                

}

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念