0
我有一个家庭作业,要求创建订单。订单表格应该包含用户可购买的项目列表,该列表来自XML文档并且使用XSL文件进行样式设置。XML - 创建订单表
我弄懂了这部分,并使用JavaScript将XSL加载到HTML DOM中。现在我一直在试图弄清楚我将如何处理数据。我需要乘以(由用户输入的)数量和价格(从XML输入)。
我完全被困住了,并且非常感谢任何提示从哪里去。
我的XSLT:
<table width="0" border="1" cellspacing="3" cellpadding="5">
<tr>
<td>Qty</td>
<td>Item Description</td>
<td>Price</td>
</tr>
<xsl:for-each select="//item">
<tr>
<td><input name="top" type="text" onchange="calculate()" value="0" size="4" /></td>
<td>Item <xsl:value-of select="id"/></td>
<td><xsl:value-of select="price"/></td>
</tr>
</xsl:for-each>
</table>
一些XML:
<productcatalog>
<item>
<id>001</id>
<name>Item #1</name>
<price>10</price>
</item>
<item>
<id>002</id>
<name>Item #2</name>
<price>20</price>
</item>
<item>
<id>003</id>
<name>Item #3</name>
<price>30</price>
</item>
<item>
<id>004</id>
<name>Item #4</name>
<price>40</price>
</item>
</productcatalog>
谢谢你的提示,阿维拉先生!如果你不介意,你能解释一下在父节点上下走路吗?我想我已经开始明白这一点了:) – 2011-12-19 03:54:09