关于xsl解析的问题
jaidy 2005-12-20 11:35:21 <?xml version="1.0" encoding="UTF-16" ?>
<root>
<ID ID="00000">
<struct classid="1085288449" aliasoffset="0">
<info mbrid="0">Microsoft XML 分析程序和 SDK</info>
<info mbrid="1">
<detail mbrid="0">2005</detail>
-
<detail mbrid="1">10</detail>
-
<detail mbrid="2">24</detail>
</info>
<info mbrid="2">4.10.9406.0</info>
<info mbrid="3">Microsoft Corporation</info>
<info mbrid="4">C:\</info>
<info mbrid="5">{3E908702-AF35-4611-9518-955DA24B7E07}</info>
</struct>
<struct classid="1085288449" aliasoffset="0">
<info mbrid="0">Microsoft Text-to-Speech Engine</info>
<info mbrid="5">MSTTS</info>
</struct>
</ID>
</root>
因为两个struct的内容不同,第二个比第一个少几个info,但是两个struct下面的info对应的意思是一样的,mbrid=0都代表程序名称,mbrid=5代表说明。
问题是,怎么在for-each的时候,正确的取得相应的info?
我的xsl这样写:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="root">
<html>
<head>
<title>汇总</title>
</head>
<body>
<table cellpadding="0" cellspacing="0" >
<tr>
<th width="100px">程序名称</th>
<th width="100px">安装日期</th>
<th width="100px">程序版本</th>
<th width="100px">公司</th>
<th width="100px">安装目录</th>
<th width="100px">程序说明</th>
</tr>
<xsl:for-each select="ID/struct">
<tr>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
<td width="150px"><xsl:value-of select="这里该怎么写?"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
由于刚接触xsl,所以还请大家帮忙,谢谢!分不够可以再加