Generate HTML

R

Rob

I've got a series of objects in memory (loaded from a database) from which I
want to generate some HTML into a file. I'm looking for something can build
an HTML document model in memory (e.g. adding nodes, nested) and then write
out the HTML, indenting as it goes along?

Thanks, Rob.
 
B

bruce barker

if you switch to xhtml, you can use the xml dom to do this.

-- bruce (sqlwork.com)
 
M

marss

I've got a series of objects in memory (loaded from a database) from which I
want to generate some HTML into a file. I'm looking for something can build
an HTML document model in memory (e.g. adding nodes, nested) and then write
out the HTML, indenting as it goes along?

Thanks, Rob.

You can do it by means of inbuilt ASP.Net functions.
Build control tree:

Panel rootElement = new Panel();
Label lbl = new Label();
lbl.Text = "test";
rootElement.Controls.Add(lbl);
....

Render root control:
StringBuilder sb = new StringBuilder();
HtmlTextWriter writer = new HtmlTextWriter(new
System.IO.StringWriter(sb));
rootElement.RenderControl(writer);

Get HTML:
string outputHTML = sb.ToString();

Regards,
Mykola
http://marss.co.ua
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top