Advice needed: create html page dynamically

In a C# DLL, I am looking for ways to create an HTML page dynamically at runtime.  The effect would be similar to taking a Word Document and replacing bookmarks with content from a database at runtime.  The HTML page has several elements:

1)  Static text that never changes.
2)  Dynamic text (often embedded at various points inside the static text)
3)  Style and formatting that needs to be applied to the entire document (Cascading Style Sheets) as well as the dynamic text.


The way I am doing it now is functional, but is very difficult to maintain because it is in one big blob.  I need an easier way to seperate content from formatting.

public void CreateGift()
                  {
                        swStreamWriter = new StreamWriter(fsFileStream); // create a stream writer
                        swStreamWriter.BaseStream.Seek(0, SeekOrigin.End); // set the file pointer to the end of file
                        swStreamWriter.WriteLine("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">");
                        swStreamWriter.WriteLine("<HTML>");
                        swStreamWriter.WriteLine("<HEAD>");
                        swStreamWriter.WriteLine("<META HTTP-EQUIV=\"CONTENT-TYPE\" CONTENT=\"text/html; charset=windows-1252\">");
                        swStreamWriter.WriteLine("<TITLE></TITLE>");
                        swStreamWriter.WriteLine("<META NAME=\"GENERATOR\" CONTENT=\"OpenOffice.org 1.1.0  (Win32)\">");
                        swStreamWriter.WriteLine("<META NAME=\"CREATED\" CONTENT=\"20031124;12125657\">");
                        swStreamWriter.WriteLine("<META NAME=\"CHANGED\" CONTENT=\"20031124;12134332\">");
                        swStreamWriter.WriteLine("<STYLE>");
                        swStreamWriter.WriteLine("<!--");
                        swStreamWriter.WriteLine("@page { size: 8.5in 11in; margin-right: 0.35in; margin-top: 0.4in; margin-bottom: 0.7in }");
                        swStreamWriter.WriteLine("P { margin-bottom: 0.08in; direction: ltr; color: #000000; widows: 2; orphans: 2 }");
                        swStreamWriter.WriteLine("P.western { font-family: \"Times New Roman\", serif; font-size: 12pt; so-language: en-US }");
                        swStreamWriter.WriteLine("P.cjk { font-family: \"Times New Roman\", serif; font-size: 12pt }");
                        swStreamWriter.WriteLine("P.ctl { font-family: \"Times New Roman\", serif; font-size: 12pt; so-language: ar-SA }");
                        swStreamWriter.WriteLine("P.text-body-indent-western { margin-left: 0.2in; font-family: \"Times New Roman\", serif; font-size: 12pt; so-language: en-US }");
                        swStreamWriter.WriteLine("P.text-body-indent-cjk { margin-left: 0.2in; font-family: \"Times New Roman\", serif; font-size: 12pt }");
                        swStreamWriter.WriteLine("P.text-body-indent-ctl { margin-left: 0.2in; font-family: \"Times New Roman\", serif; font-size: 12pt; so-language: ar-SA }");
                        swStreamWriter.WriteLine("A:link { color: #0000ff }");
                        swStreamWriter.WriteLine("-->");
                        swStreamWriter.WriteLine("</STYLE>");
                        swStreamWriter.WriteLine("</HEAD>");
                        swStreamWriter.WriteLine("<BODY LANG=\"en-US\" TEXT=\"#000000\" LINK=\"#0000ff\" DIR=\"LTR\">");
                        swStreamWriter.WriteLine("<DIV TYPE=HEADER>");
                        swStreamWriter.WriteLine("<P ALIGN=RIGHT STYLE=\"margin-bottom: 0.3in\"><IMG SRC=\"bf.gif\" NAME=\"Graphic2\" ALIGN=BOTTOM WIDTH=190 HEIGHT=82 BORDER=0></P>");
                        swStreamWriter.WriteLine("</DIV>");
                        swStreamWriter.WriteLine("<P CLASS=\"text-body-indent-western\"><BR><BR>");
                        swStreamWriter.WriteLine("</P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\">");
                        swStreamWriter.WriteLine("<FONT FACE=\"Verdana, sans-serif\"><FONT SIZE=5 STYLE=\"font-size: 20pt\"><B>Buyers");
                        swStreamWriter.WriteLine("Fund Gift Letter</B></FONT></FONT></P>");
                        swStreamWriter.WriteLine("<DL>");
                        swStreamWriter.WriteLine("<DL>");
                        swStreamWriter.WriteLine("<DD>");
                        swStreamWriter.WriteLine("<TABLE WIDTH=601 BORDER=1 BORDERCOLOR=\"#000000\" CELLPADDING=0 CELLSPACING=0 FRAME=BELOW RULES=ROWS>");
                        swStreamWriter.WriteLine("<COL WIDTH=84>");
                        swStreamWriter.WriteLine("<COL WIDTH=217>");
                        swStreamWriter.WriteLine("<COL WIDTH=62>");
                        swStreamWriter.WriteLine("<COL WIDTH=237>");
                        swStreamWriter.WriteLine("<TR VALIGN=TOP>");
                        swStreamWriter.WriteLine("<TD WIDTH=84>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><FONT SIZE=2><FONT FACE=\"Arial, sans-serif\"><FONT SIZE=2 STYLE=\"font-size: 9pt\"><B><FONT SIZE=3><FONT FACE=\"Garamond, serif\">To:</FONT></FONT></B></FONT></FONT></FONT></P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("<TD WIDTH=217>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><A NAME=\"lo_fff12_1\"></A> ");
                        swStreamWriter.WriteLine("</P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("<TD WIDTH=62>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><FONT SIZE=2><FONT FACE=\"Arial, sans-serif\"><FONT SIZE=2 STYLE=\"font-size: 9pt\"><B><FONT SIZE=3><FONT FACE=\"Garamond, serif\">From:</FONT></FONT></B></FONT></FONT></FONT></P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("<TD WIDTH=237>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><FONT FACE=\"Garamond, serif\"><FONT SIZE=3>Buyers");
                        swStreamWriter.WriteLine("Fund</FONT></FONT></P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("</TR>");
                        swStreamWriter.WriteLine("<TR VALIGN=TOP>");
                        swStreamWriter.WriteLine("<TD WIDTH=84>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><FONT SIZE=2><FONT FACE=\"Arial, sans-serif\"><FONT SIZE=2 STYLE=\"font-size: 9pt\"><B><FONT SIZE=3><FONT FACE=\"Garamond, serif\">Fax:</FONT></FONT></B></FONT></FONT></FONT></P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("<TD WIDTH=217>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><A NAME=\"LenderFax_fff12_1\"></A> ");
                        swStreamWriter.WriteLine("</P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("<TD WIDTH=62>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><FONT SIZE=2><FONT FACE=\"Arial, sans-serif\"><FONT SIZE=2 STYLE=\"font-size: 9pt\"><B><FONT SIZE=3><FONT FACE=\"Garamond, serif\">Fax</FONT></FONT></B></FONT></FONT><FONT SIZE=3><FONT FACE=\"Garamond, serif\">:</FONT></FONT></FONT></P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("<TD WIDTH=237>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><FONT FACE=\"Garamond, serif\"><FONT SIZE=3>888-523-8983;");
                        swStreamWriter.WriteLine("801-734-1364</FONT></FONT></P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("</TR>");
                        swStreamWriter.WriteLine("<TR VALIGN=TOP>");
                        swStreamWriter.WriteLine("<TD WIDTH=84>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><FONT SIZE=2><FONT FACE=\"Arial, sans-serif\"><FONT SIZE=2 STYLE=\"font-size: 9pt\"><B><FONT SIZE=3><FONT FACE=\"Garamond, serif\">Company:</FONT></FONT></B></FONT></FONT></FONT></P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("<TD WIDTH=217>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><A NAME=\"Lender_fff12_1\"></A> ");
                        swStreamWriter.WriteLine("</P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("<TD WIDTH=62>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><FONT SIZE=2><FONT FACE=\"Arial, sans-serif\"><FONT SIZE=2 STYLE=\"font-size: 9pt\"><B><FONT SIZE=3><FONT FACE=\"Garamond, serif\">Phone:</FONT></FONT></B></FONT></FONT></FONT></P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("<TD WIDTH=237>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-left: 0.12in; text-indent: -0.12in; margin-top: 0.17in\">");
                        swStreamWriter.WriteLine("<FONT FACE=\"Garamond, serif\"><FONT SIZE=3>888-228-2279</FONT></FONT></P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("</TR>");
                        swStreamWriter.WriteLine("<TR VALIGN=TOP>");
                        swStreamWriter.WriteLine("<TD WIDTH=84>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><FONT SIZE=2><FONT FACE=\"Arial, sans-serif\"><FONT SIZE=2 STYLE=\"font-size: 9pt\"><B><FONT SIZE=3><FONT FACE=\"Garamond, serif\">Sent:</FONT></FONT></B></FONT></FONT></FONT></P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("<TD WIDTH=217>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><SDFIELD TYPE=DATETIME SDNUM=\"1033;1033;M/D/YYYY H:MM:SS AM/PM\">11/24/2003 12:13:44 pm</SDFIELD></P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("<TD WIDTH=62>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><FONT FACE=\"Garamond, serif\"><FONT SIZE=3><B>Pages:</B></FONT></FONT></P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("<TD WIDTH=237>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><FONT FACE=\"Garamond, serif\"><FONT SIZE=3>3,");
                        swStreamWriter.WriteLine("including cover</FONT></FONT></P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("</TR>");
                        swStreamWriter.WriteLine("<TR VALIGN=TOP>");
                        swStreamWriter.WriteLine("<TD WIDTH=84>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><FONT SIZE=2><FONT FACE=\"Arial, sans-serif\"><FONT SIZE=2 STYLE=\"font-size: 9pt\"><B><FONT SIZE=3><FONT FACE=\"Garamond, serif\">Subject:</FONT></FONT></B></FONT></FONT></FONT></P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("<TD COLSPAN=3 WIDTH=517>");
                        swStreamWriter.WriteLine("<P STYLE=\"margin-top: 0.17in\"><A NAME=\"Buyer_fff12_1\"></A><A NAME=\"EntryId_fff12_1\"></A>");
                        swStreamWriter.WriteLine("<FONT SIZE=2><FONT SIZE=3><FONT FACE=\"Garamond, serif\">Gift");
                        swStreamWriter.WriteLine("Letter for<B>  , #</B></FONT></FONT></FONT></P>");
                        swStreamWriter.WriteLine("</TD>");
                        swStreamWriter.WriteLine("</TR>");
                        swStreamWriter.WriteLine("</TABLE>");
                        swStreamWriter.WriteLine("</DL>");
                        swStreamWriter.WriteLine("</DL>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\">");
                        swStreamWriter.WriteLine("<BR>");
                        swStreamWriter.WriteLine("</P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\">");
                        swStreamWriter.WriteLine("<FONT FACE=\"Verdana, sans-serif\"><FONT SIZE=4><B>Message:</B></FONT></FONT></P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\">");
                        swStreamWriter.WriteLine("<BR>");
                        swStreamWriter.WriteLine("</P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\"><A NAME=\"lo_fff11_2\"></A>");
                        swStreamWriter.WriteLine("<FONT SIZE=2 STYLE=\"font-size: 11pt\"><FONT FACE=\"Garamond, serif\">Dear");
                        swStreamWriter.WriteLine("<B> </B>,</FONT></FONT></P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\">");
                        swStreamWriter.WriteLine("<BR>");
                        swStreamWriter.WriteLine("</P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\">");
                        swStreamWriter.WriteLine("<FONT FACE=\"Garamond, serif\"><FONT SIZE=2 STYLE=\"font-size: 11pt\">Thank");
                        swStreamWriter.WriteLine("you for the new grant application.</FONT></FONT></P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\">");
                        swStreamWriter.WriteLine("<FONT FACE=\"Garamond, serif\"><FONT SIZE=2 STYLE=\"font-size: 11pt\">We");
                        swStreamWriter.WriteLine("appreciate your business.</FONT></FONT></P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\">");
                        swStreamWriter.WriteLine("<FONT FACE=\"Garamond, serif\"><FONT SIZE=2 STYLE=\"font-size: 11pt\">We");
                        swStreamWriter.WriteLine("will contact the title company today to send out closing");
                        swStreamWriter.WriteLine("instructions.</FONT></FONT></P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\">");
                        swStreamWriter.WriteLine("<BR>");
                        swStreamWriter.WriteLine("</P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\">");
                        swStreamWriter.WriteLine("<FONT FACE=\"Garamond, serif\"><FONT SIZE=2 STYLE=\"font-size: 11pt\">Sincerely,</FONT></FONT></P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\">");
                        swStreamWriter.WriteLine("<FONT FACE=\"Garamond, serif\"><FONT SIZE=2 STYLE=\"font-size: 11pt\">Buyers");
                        swStreamWriter.WriteLine("Fund Processing Department</FONT></FONT></P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\">");
                        swStreamWriter.WriteLine("<BR>");
                        swStreamWriter.WriteLine("</P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\">");
                        swStreamWriter.WriteLine("<FONT FACE=\"Garamond, serif\"><FONT SIZE=2 STYLE=\"font-size: 11pt\"><B>Gift");
                        swStreamWriter.WriteLine("Letter Instructions:</B></FONT></FONT></P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\">");
                        swStreamWriter.WriteLine("<BR>");
                        swStreamWriter.WriteLine("</P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\">");
                        swStreamWriter.WriteLine("<FONT FACE=\"Garamond, serif\"><FONT SIZE=2 STYLE=\"font-size: 11pt\">1.");
                        swStreamWriter.WriteLine("To validate the Gift Letter, have the home buyer sign it. This must");
                        swStreamWriter.WriteLine("be done before using it as proof of down payment (i.e. with FHA).</FONT></FONT></P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\">");
                        swStreamWriter.WriteLine("<FONT FACE=\"Garamond, serif\"><FONT SIZE=2 STYLE=\"font-size: 11pt\">2.");
                        swStreamWriter.WriteLine("You do not need to send the gift letter back to us. This letter is to");
                        swStreamWriter.WriteLine("be presented to the homebuyer, and copies of it are to be used as you");
                        swStreamWriter.WriteLine("see fit.</FONT></FONT></P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\"><A NAME=\"GrantAmount_fff11_1\"></A>");
                        swStreamWriter.WriteLine("<FONT SIZE=2 STYLE=\"font-size: 11pt\"><FONT FACE=\"Garamond, serif\">3.");
                        swStreamWriter.WriteLine("The grant your buyer has been approved for is <B> </B>.</FONT></FONT></P>");
                        swStreamWriter.WriteLine("<P CLASS=\"western\" ALIGN=JUSTIFY STYLE=\"margin-left: 0.75in; margin-right: 0.75in; margin-bottom: 0in\"><A NAME=\"GrantAmount_fff11_2\"></A>");
                        swStreamWriter.WriteLine("<FONT SIZE=2 STYLE=\"font-size: 11pt\"><FONT FACE=\"Garamond, serif\">4.");
                        swStreamWriter.WriteLine("The seller service fee paid by the seller to Buyers Fund is the grant");
                        swStreamWriter.WriteLine("(<B> </B>) <I>and</I> the net fee.</FONT></FONT></P>");
                        swStreamWriter.WriteLine("</DIV>");
                        swStreamWriter.WriteLine("</BODY>");
                        swStreamWriter.WriteLine("</HTML>");

                        swStreamWriter.Flush(); // update underlying file
                        swStreamWriter.Close();



                  }
LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ptmcompCommented:
There are several solutions:
- a local webserver and asp.net.
- Template as file with special placeholders (e.g. $TEXT1$) that you replace with string.Replace or Regular Expressions
- Template with asp like tags that you use to create a WebControls and render them
0
testnCommented:
Try this tool. You can separate the template from the code easily.
http://nvelocity.sourceforge.net/
0
testnCommented:
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

AaniaCommented:
Depending on how you're accessing this data, one of the easiest ways is probably to do something similar to what ptmcomp already said, and store the page somewhere (in a database or a file) with some variables that you can easily search for and replace.
To give a more specific example on how this might be done, you could do the following:

SQL Table: TBLTemplates

templateID    HTML
-------------   --------
1                  <HTML><HEAD></HEAD><BODY>Hello $$NAME$$!</BODY></HTML>

Then in your C#, you would retrieve the HTML into a string:

mySQLCommand = new System.Data.SqlClient.SqlCommand("SELECT HTML FROM TBLTemplates WHERE templateID = 1", myConnection);
myConnection.Open();
string template = mySQLCommand.ExecuteScalar().ToString();
myConnection.Close();

// And then replace t he place holders with your values

string name = "Vanessa"; //Retrieve the dynamic information
template = template.Replace("$$NAME$$", name); //Insert it into the template

Response.Write(template);

And you will get
<HTML><HEAD></HEAD><BODY>Hello Vanessa!</BODY></HTML>

I hope that helps,
Thanks,
Vanessa
0
AJMartinCommented:
Another tip is to use CSS Stylesheets to reduce the volume of styling information you're sending and the number of WriteLine-s in your code.

Another tip is to use XML transformations which are in C# to transform a source XML document into HTML. Have a look at this page:
ms-help://MS.NETFrameworkSDKv1.1/cpguidenf/html/cpconxslttransformationswithxsltransformclass.htm
It's in the MS .NET Framework SDK.

Here's an example from the documentation:
The following code example loads an XSL style sheet, reads a file called mydata.xml into an XPathDocument, and performs a transformation on the data on a fictitious file called myStyleSheet.xsl, sending the formatted output to the console.

using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;

public class Sample
{
    private const String filename = "mydata.xml";
    private const String stylesheet = "myStyleSheet.xsl";

    public static void Main()
    {
    XslTransform xslt = new XslTransform();
    xslt.Load(stylesheet);
    XPathDocument xpathdocument = new
    XPathDocument(filename);
    XmlTextWriter writer = new XmlTextWriter(Console.Out);
    writer.Formatting=Formatting.Indented;

    xslt.Transform(xpathdocument, null, writer, null);    
    }
}

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tom KnowltonWeb developerAuthor Commented:
Thank you for the suggestions.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.