XSLT - how to use it

  • Thread starter Thread starter Dan Aldean
  • Start date Start date
D

Dan Aldean

Hello,

I would like to convert an XML document to HTML.

1. Can I build with the design tools the xslt document, or I have to write
code?
2. Does anybody have a small sample of C# of how to do the transformation?
Also the xml and xsl attached?

Thanks
 
Dan Aldean wrote:

I would like to convert an XML document to HTML.

1. Can I build with the design tools the xslt document, or I have to write
code?

There are generic stylesheets that for instance render the XML tree as
an HTML document with script but usually you have to write a custom XSLT
stylesheet for your XML documents.
2. Does anybody have a small sample of C# of how to do the transformation?

..NET 1.x:
<http://samples.gotdotnet.com/quickstart/howto//doc/Xml/TransformXml.aspx>

..NET 2.0:
<http://www.asp.net/quickstart/howto/doc/Xml/TransformXml_Retail.aspx>
 
1. I don't know if you can with the design tools

2. This code snippet is all required. Unfortunately, I cannot post the
xml/xslt pair :)

_document is an XMLDocument

XslTransform transform1 = new XslTransform();
transform1.Load(this.XsltPath);
TextWriter writer1 = new StreamWriter(strOutputPath, false,
Encoding.UTF8);
transform1.Transform(this._document.CreateNavigator(), null, writer1);
writer1.Flush();
writer1.Close();


Regards,
Tasos
 
1. I don't know if you can with the design tools

In Visual Studio 2005, yes, you can. The XSL Editor is excellent!

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

The man who questions opinions is wise.
The man who quarrels with facts is a fool.
 
Thank you all.

I previously tried a few of the samples I found on the web, but all had
problems and did not even compile. Nor that I knew how to fix them.

Regards,
Dan
 
Back
Top