tags:

views:

27

answers:

3

I would like to write application which will iterate trough certain test cases and generated output in HTML file.

For this i would like to have something using which i can keep appending the HTML nodes to the output for each test case. Is there nice way in .NET for doing so ? How ?

Any pointers or suggestions will be helpful.

+4  A: 

You can use an XmlWriter that uses a MemoryStream as the base stream.

XmlWriter inMemHTML = XmlWriter.Create(new MemoryStream());
Oded
+2  A: 

If you want to do this the XML way, you can use the XmlDocument class (http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx) to help generate XML. Obviously you will be generating XHTML as your output.

Another alternative would be to generate XML in some other dialect (one you make up to suit your business needs for example), and then transform the generated XML into XHTML using XSLT.

It's also worth asking if the XML step is needed at all. You could for example use the StringBuilder class to generate HTML as a string.

Hope this helps.

David

David
StringBuilder is great but i am just tired of sticking to old known things. I just want to take this opportunity to learn and use new things which are out there and i don't know :) thanks
Anil Namde
Learn yourself some XML then! You can take it anywhere.
David
A: 

You can use XElement, XDocument and others, too.

I do not know how this would handle nodes that must not be empty, i.e.

<br />
<div></div>

just in case you want to generate XHTML.

Arne