SP.XmlWriter Class
Applies to: SharePoint Foundation 2010
Defines a writer that provides a set of methods to append text in XML format.
SP.XmlWriter
Remarks
Use the static SP.XmlWriter.create(sb) Method to create an SP.XmlWriter object with the Sys.StringBuilder object you pass in. Use that StringBuilder object in calls to the other SP.XmlWriter methods that append to the StringBuilder object. If you forget to close a tag or attribute before you open a new tag or attribute, the method to open a new tag or attribute throws an exception.