XML message generation
I need to generate some XML message, but the message can not be reflected from members or properties of class instance directly.
Currently, I am using StringBuilder to append strings into XML message manually (e.g. to generate the element's hierarchies and add attributes to element), I think this method is stupid.
Any better approaches recommended?
thanks in advance,
Use XmlDocument/XmlElement instead of StringBuilder perhaps ?
I read some documents for XMLDocument and XMLElement, looks like we need to use DOM model, right?
I have not found some good samples for a beginner, I have XML knowledge before and just want to learn how to use the C# classes. Any referred samples?
Originally Posted by nvoigt
Look up System.Xml.XmlWriter as it has some neat features, like buildt-in indentation. Either build up an XmlDocument and save it to the writer, or write each node yourself manually. Either way works, and can even be combined to some extent.
Any pros and cons compared with XMLTextWriter and XMLDocument from functional and performance perspective?
Originally Posted by Magos