Skip item if null for xml text writer
See the question and my original answer on StackOverflowMaybe you could use a C# class that represents the data what you want to save, and an XmlSerializer to serialize all this (with an XmlTextWriter as an input) because Xml Serialization handles null implicitely gracefully.