Create a CSBlog topic-use the compile compiledtransform object to output XML data to other formats

Source: Internet
Author: User
Tags xsl xslt

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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.