请给出一段xslt代码,使用xml数据输出如下HTML数据:xml:
<cellphones>
<brand name="Moto">
<product name="A3000" publish_year = "2008" platform = "windows"/>
<product name="A3100" publish_year = "2009" platform= "windows"/>
<product name="Droid" publish_year = "2009" platform= "android"/>
</brand>
<brand name="HTC">
<product name="Tatoo" publish_year = "2009" platform= "android"/>
<product name="Hero" publish_year = "2009" platform= "android"/>
<product name="Touch Pro II" publish_year = "2009" platform= "windows"/>
<product name="Dream" publish_year = "2008" platform= "android"/>
</brand>
<brand name="Nokia">
<product name="N97" publish_year = "2009" platform= "symbian"/>
<product name="E71" publish_year = "2008" platform= "symbian"/>
<product name="N73" publish_year = "2007" platform= "symbian"/>
</brand>
</cellphones> html:<table>
<tr>
<td rowspan="3">
Moto
</td>
<td>A3000</td>
<td>2008</td>
<td>windows</td>
</tr>
<tr>
<td>A3100</td>
<td>2009</td>
<td>windows</td>
</tr>
<tr>
<td>Droid</td>
<td>2009</td>
<td>android</td>
</tr>
<tr>
<td rowspan="4">
HTC
</td>
<td>Tatoo</td>
<td>2009</td>
<td>android</td>
</tr>
<tr>
<td>Hero</td>
<td>2009</td>
<td>android</td>
</tr>
<tr>
<td>Touch Pro II</td>
<td>2009</td>
<td>windows</td>
</tr>
<tr>
<td>Dream</td>
<td>2008</td>
<td>android</td>
</tr>
<tr>
<td rowspan="3">
Nokia
</td>
<td>N97</td>
<td>2009</td>
<td>symbian</td>
</tr>
<tr>
<td>E71</td>
<td>2009</td>
<td>symbian</td>
</tr>
<tr>
<td>N73</td>
<td>2007</td>
<td>symbian</td>
</tr>
</table>
<cellphones>
<brand name="Moto">
<product name="A3000" publish_year = "2008" platform = "windows"/>
<product name="A3100" publish_year = "2009" platform= "windows"/>
<product name="Droid" publish_year = "2009" platform= "android"/>
</brand>
<brand name="HTC">
<product name="Tatoo" publish_year = "2009" platform= "android"/>
<product name="Hero" publish_year = "2009" platform= "android"/>
<product name="Touch Pro II" publish_year = "2009" platform= "windows"/>
<product name="Dream" publish_year = "2008" platform= "android"/>
</brand>
<brand name="Nokia">
<product name="N97" publish_year = "2009" platform= "symbian"/>
<product name="E71" publish_year = "2008" platform= "symbian"/>
<product name="N73" publish_year = "2007" platform= "symbian"/>
</brand>
</cellphones> html:<table>
<tr>
<td rowspan="3">
Moto
</td>
<td>A3000</td>
<td>2008</td>
<td>windows</td>
</tr>
<tr>
<td>A3100</td>
<td>2009</td>
<td>windows</td>
</tr>
<tr>
<td>Droid</td>
<td>2009</td>
<td>android</td>
</tr>
<tr>
<td rowspan="4">
HTC
</td>
<td>Tatoo</td>
<td>2009</td>
<td>android</td>
</tr>
<tr>
<td>Hero</td>
<td>2009</td>
<td>android</td>
</tr>
<tr>
<td>Touch Pro II</td>
<td>2009</td>
<td>windows</td>
</tr>
<tr>
<td>Dream</td>
<td>2008</td>
<td>android</td>
</tr>
<tr>
<td rowspan="3">
Nokia
</td>
<td>N97</td>
<td>2009</td>
<td>symbian</td>
</tr>
<tr>
<td>E71</td>
<td>2009</td>
<td>symbian</td>
</tr>
<tr>
<td>N73</td>
<td>2007</td>
<td>symbian</td>
</tr>
</table>
解决方案 »
- 如何删除有数组绑定的gridview项
- 动态生成。m3u文件(麻烦各位高人指教)
- 为什么我做的站点访问和运行总是很慢?
- getmail=ds.Tables["jobse"].Rows[0]["mv"]; 在c#里写这种是否错误
- excel文件里面,如何得出文件表的名字。[webform应用]
- caja是什么意思
- 按“分数”排序,等级分别为:10%优,20%良,60%合格,10%不合格。如何把等级存到“等级”一列?
- 求助高手~~为何初始化页面之后显示不出来。。
- 好久没发贴了,做个调查散散分
- js带参数调用后台函数无效?
- 如何使用DataList控件分页(asp.net)
- vs2005插入falsh
dom.LoadXml(xml);
foreach (System.Xml.XmlNode node in dom.ChildNodes)
{
if(node.Name !="xml")
Response.Write(GetNode(node));
}
string GetNode(System.Xml.XmlNode node)
{
string str = node.InnerText;
str+=node.Attributes["name"].InnerText.Trim()
if (node.HasChildNodes)
{
str = "";
foreach (System.Xml.XmlNode n in node.ChildNodes)
{
str += GetNode(n);
}
}
return str;
}
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="phone.xsl"?>
<cellphones>
<brand name="Moto">
<product name="A3000" publish_year = "2008" platform = "windows"/>
<product name="A3100" publish_year = "2009" platform= "windows"/>
<product name="Droid" publish_year = "2009" platform= "android"/>
</brand>
<brand name="HTC">
<product name="Tatoo" publish_year = "2009" platform= "android"/>
<product name="Hero" publish_year = "2009" platform= "android"/>
<product name="Touch Pro II" publish_year = "2009" platform= "windows"/>
<product name="Dream" publish_year = "2008" platform= "android"/>
</brand>
<brand name="Nokia">
<product name="N97" publish_year = "2009" platform= "symbian"/>
<product name="E71" publish_year = "2008" platform= "symbian"/>
<product name="N73" publish_year = "2007" platform= "symbian"/>
</brand>
</cellphones>phone.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method='html' version='1.0' encoding='ISO-8859-1' indent='yes'/>
<xsl:template match="/">
<html>
<body>
<table border="1">
<xsl:for-each select="cellphones/brand">
<xsl:for-each select="product">
<tr>
<xsl:if test="position()=1">
<td>
<xsl:attribute name="rowspan">
<xsl:value-of select="count(../product)"/>
</xsl:attribute>
<xsl:value-of select="../@name"/>
</td>
</xsl:if>
<td>
<xsl:value-of select="@name"/>
</td>
<td>
<xsl:value-of select="@publish_year"/>
</td>
<td>
<xsl:value-of select="@platform"/>
</td>
</tr>
</xsl:for-each>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
http://www.cnblogs.com/yeti/articles/667117.html另,结贴率太低!