By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,981 Members | 1,098 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,981 IT Pros & Developers. It's quick & easy.

XSLT - how to use it

P: n/a
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
May 19 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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.CreateNavigato r(), null, writer1);
writer1.Flush();
writer1.Close();
Regards,
Tasos

May 19 '06 #2

P: n/a


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>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 19 '06 #3

P: n/a
> 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.

"Tasos Vogiatzoglou" <tv*****@gmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
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.CreateNavigato r(), null, writer1);
writer1.Flush();
writer1.Close();
Regards,
Tasos

May 19 '06 #4

P: n/a
The MSDN Library has an excellent reference:

http://msdn.microsoft.com/library/en...asp?frame=true

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

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

"Dan Aldean" <da*******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
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

May 19 '06 #5

P: n/a
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

"Dan Aldean" <da*******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
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

May 19 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.