xls 和 xml 排序
xml:
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type= "text/xsl" href= "test.xsl"?> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <languages> <languageList> <language name="Chinese" > <codeList > <code >zh</code> </codeList> </language> <language name="English" > <codeList > <code >en</code> </codeList> </language> </languageList> </languages>
xsl:
<?xml version="1.0" encoding="UTF-8"?> <!-- Document : test.xsl Created on : 2013年12月26日, 下午9:37 Author : ideaam Description: Purpose of transformation follows. --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:variable name="vsortKey" select="'name'"/> <xsl:variable name="vsortOrder" select="'descending'"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"> <xsl:sort select="/language[name()=$vsortKey] | @*[name()=$vsortKey]" data-type="text" order="{$vsortOrder}"/> <xsl:sort select="@*" /> </xsl:apply-templates> </xsl:copy> </xsl:template> </xsl:stylesheet>
WebForm DataBind:
<asp:ListView ID="ListView1" runat="server" DataSourceID="XmlDataSource1"> <ItemTemplate> <label><%#Eval("name")%></label> </ItemTemplate> </asp:ListView> <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/test.xml" XPath="//language" TransformFile="~/test.xsl"></asp:XmlDataSource>