XML support in .NET includes XML generation classes, although in my opinion they dont add much to the situation over and above regular string manipulation. You can validate XML with a class named XMLValidatingReader. Theres an XMLDocument class that could be used as the base for TextModel instead of the tree. You can load XML into the document with XMLTextReader and then navigate through it.
Using such tools has its pros and cons. Certainly, so far, weve stayed away from them in this book. My reasons arent just not invented here. I like to learn how things really work, down at the bits and bytes, so even if we were to use some of the classes just mentionedand we may well experiment with them before the project is overI like to start with simple and direct solutions. In addition, it typically takes a lot of learning to get one of these solutions doing anything, especially when you dont know your way around the system very well. Ive got a pretty good feeling now for how C# and .NET work, and I feel I can put together some interesting tests of these classes in a few hours. But when I was just starting out, it would have taken much longer and I would have been learning some high-level material but missing out on the basics.
So my practice is to start with the basics. Often, it works just fine to stay there. Other times, it makes sense to move to a more powerful tool, but when we do, we have enough of a grasp of the realities of the problem to enable us to navigate the tool wisely. Well see how things go this time.