I am thinking about creating a C# program that applies an XSL-T to XML to convert it to HTML. any ideas as to how difficult that might be ?

Recommended Answers

All 7 Replies

Thanks! Now off to rip off your idea and sell it on ebay for an extra kidney.

Honestly, sounds like an interesting thing to code. My guess is that it shouldn't be *that* hard. Here's to hoping you don't get bored of everything you start like I do. (Today I dropped a project I was planning to start yesterday, but never did)

commented: Funny Answer, and thanks for my rep points dude. +1

lol i know what you mean with the boredom!! Its all too easy to start.......but to finish thats another thing!

i'll let you know how I get on and if I have any problems !

initial planning has gone well, need to start coding soon. not written DLL's before so this is a good experience

Thanks! Now off to rip off your idea and sell it on ebay for an extra kidney.

Honestly, sounds like an interesting thing to code. My guess is that it shouldn't be *that* hard. Here's to hoping you don't get bored of everything you start like I do. (Today I dropped a project I was planning to start yesterday, but never did)

just had a great idea to expand the functionality of this project....lol but should probably keep it to myself!

open I give u a simple way to do that throw this example:

open a new bloc note
copy and paste this :

<?xml version="1.0" encoding="utf-8" ?>
<Cars>
<Car>
<Name>Car1</Name>
<MaxSpeed>200 Km/h</MaxSpeed>
</Car>
<Car>
<Name>Car2</Name>
<MaxSpeed>220 Km/h</MaxSpeed>
</Car>
<Car>
<Name>Car3</Name>
<MaxSpeed>250 Km/h</MaxSpeed>
</Car>
</Cars>
save this file as C:\xmlFile.xml
then open a new bloc note and copy and paste this:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table>
<tr>
<th>Name</th>
<th>Maximum of speed</th>
</tr>
<xsl:for-each select="Cars/Car">
<tr>
<td>
<xsl:value-of select="Name"/>
</td>
<td>
<xsl:value-of select="MaxSpeed" />
</td>
</tr>
</xsl:for-each>

</table>

</xsl:template>
</xsl:stylesheet>
save it as C:\xslFile.xsl

now open a new project and excute those lines of code:
XslCompiledTransform oProcessor = new XslCompiledTransform();
oProcessor.Load(@"C:\xslFile.xsl");
oProcessor.Transform(@"C:\xmlFile.xml", @"C:\xslFile.html");
MessageBox.Show("The job id done");
now browse to
C:\xslFile.html and open it.
Thar's all

don't forget to include thoses directories:
System.xml and System.xml.xsl enjoy your self

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.