The problem is that you're trying to create an element with a name of rss version="2.0"
. Instead, you should be creating an element with a name of rss
, and setting the version
attribute to have a value of 2.0
:
xw.WriteStartElement("rss");xw.WriteAttributeString("version", "2.0");
Personally I'd use LINQ to XML instead of XmlWriter
to start with, mind you - it's a much nicer API.