I am using XmlWriter and I am wondering if some one ever tried to write the xml element string (leaf node) with attributes so that the output would look like
<book id='1' author='j.k.rowling' year='2010'>999</book>
instead of
<book id='1' author='j.k.rowling' year='2010'> <book>999</book> </book>
You can use 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(); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With