Q:

How do I set Indent property on XmlWriter for specific element node

Sorry if title is confusing, here is what I want to achieve.  I have a XmlWriter object that is being created and passed to a method
public static void foo(XmlWriter xw)
{
   xw. WriteStartElement("root");
}

At this point XmlWriter was instantiated, and Xml declaration was already written.  Now, afer the root element is written, I need to set Indent property on XmlWriter to true ( it was set to false when XmlWriter was created ).  Something like this
public static void foo(XmlWriter xw)
{
   xw. WriteStartElement("root");
   // xw. Settings. Indent = true; - I know this won't work
   // continue writing elements...
}

Can't find a way how to set Indent at that point.  Any ideas ? 

A:

use XmlTextWriter.  You can then set the Indentation property to the number of spaces you want to indent.  http://msdn.microsoft.com/en-us/library/system.xml.xmltextwriter.indentation.aspx
To use the Indent property, you can't have mixed content
http://msdn.microsoft.com/en-us/library/system.xml.xmlwritersettings.indent.aspx
"The elements are indented as long as the element does not contain mixed content.  Once the WriteString or WriteWhitespace method is called to write out a mixed element content, the XmlWriter stops indenting.  The indenting resumes once the mixed content element is closed."