Generate HTML

  • Thread starter Thread starter Rob
  • Start date Start date
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.
 
if you switch to xhtml, you can use the xml dom to do this.

-- bruce (sqlwork.com)
 
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
 
Back
Top