I need to generate an XML file in C#.
I want to write the code that generates this in a file that is mostly XML with code inside of it as I can in an ASP.NET MVC page.
So I want a code file that looks like:
<lots of angle brackets...> <% foreach(data in myData) { %> < <%= data.somefield %> <% } %> More angle brackets>
This would generate my XML file. I would not mind using part of System.Web if someone tells me how I can do it without IIS overhead or kludging a generation of a web file.
I want to use templating and I want templating that is similar to ASP.NET
First off, its MUCH easier to generate XML using XElements. There are many examples floating around. Just search for ‘Linq to XML.’
Alternatively, if you absolutely need to do templating, I’d suggest using a template engine such as NVelocity rather than trying to kludge ASP.NET into doing it for you.