Prepare an XML file first:
Code
<? XML version = "1.0" encoding = "UTF-8"?>
<Links>
<Link name = "google" url = "http://www.google.com"/>
<Link name = "lovecherry" url = "http://www.cnblogs.com/lovecherry"/>
<Link name = "csdn. Net" url = "http://www.csdn.net"/>
<Link name = "blog Garden" url = "http://www.cnblogs.com/"/>
<Link name = "contaminated blog" url = "http://blog.csdn.net/wuhuiran"/>
<Link name = "play Wild network" url = "http://www.playes.net/"/>
<Link name = "AJ: bar" url = "http://www.aj98.com/"/>
<Link Name = "talent: Talent note" Url = "http://blog.54caizi.com/blog/"/>
<Link Name = "DLL: New Hope" Url = "http://www.byval.org/"/>
<Link Name = "SOUL: wooden bird original" Url = "http://www.psder.com/"/>
<Link Name = "smiling practices's blog" Url = "http://blog.knoweb.cn/"/>
<Link Name = "tianyao technology" Url = "http://www.69sea.com"/>
<Link Name = "" Url = "http://blog.cnfol.com/xielina82782114"/>
<Link Name = "Devms Forum" Url = "http://bbs.devms.com" LogoUrl = "/Images/Links/dmfourm.jpg" Title = "Asp. Net Commitury."/>
</Links>
Prepare another XSLT Template File
Code
<? Xml version = "1.0" encoding = "UTF-8"?>
<Xsl: stylesheetversion = "2.0"
Xmlns: xsl = "http://www.w3.org/1999/XSL/Transform"
>
<Xsl: variable name = "Links" select = "/Links/Link"/>
<Xsl: output
Method = "xhtml"
Version = "1.0"
Encoding = "UTF-8"
Omit-xml-declaration = "no"
Indent = "yes"
Media-type = "application/XHTML + XML"
Doctype-Public = "-// W3C // dtd xhtml 1.0 transitional // en"
Doctype-system = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
/>
<XSL: template match = "/">
<XSL: Call-Template Name = "T. linkpanel"/>
</XSL: Template>
<XSL: Template Name = "T. linkpanel">
<Div>
<Ol>
<Xsl: for-each select = "$ Links">
<Li> <xsl: value-of select = "@ Name"/> </li>
</Xsl: for-each>
</Ol>
</Div>
</Xsl: template>
</Xsl: stylesheet>
Then C # converts the Code to Code.
Extends compiledtransform xsl = new extends compiledtransform ();
Xsl. Load (@ "C: \ Web \ T. xslt ");
Xsl. Transform (@ "C: \ Web \ Links. xml", @ "C: \ Web \ Link.html ");
Output result after execution:
Code
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE div PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Div>
<Ol>
<Li> Google </li>
<Li> LoveCherry </li>
<Li> CSDN. Net </li>
<Li> blog </li>
<Li> contaminated Blog </li>
<Li> playye Network </li>
<Li> AJ: bar </li>
<Li> talents: talents </li>
<Li> DLL: New Hope </li>
<Li> SOUL: Original wooden bird </li>
<Li> slogan's blog </li>
<Li> tianyao technology </li>
<Li> heimei blog </li>
<Li> Devms Forum </li>
</Ol>
</Div>
How is it? Is it super simple? Oh ~~~
To be continued...