用xsl很好实现,不知合不合你的要求
<?xml version="1.0" encoding="gb2312"?>
<?xml:stylesheet type="text/xsl" href="mywork.xsl"?>
<XML ID="XMLDATA">
<root>
<Item>
<text> abc </text>
<value> abc </value>
</Item>
<Item>
<text> efg </text>
<value> efg </value>
</Item>
</root>
</XML>mywork.xsl文件为:
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<select name="select" size="2" multiple="multiple">
<xsl:apply-templates select="//Item"/>
</select>
</html>
</xsl:template>
<xsl:template match="Item">
<option>
<xsl:attribute name="value">
<xsl:value-of select="value"/>
</xsl:attribute>
<xsl:value-of select="text"/>
</option>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="gb2312"?>
<?xml:stylesheet type="text/xsl" href="mywork.xsl"?>
<XML ID="XMLDATA">
<root>
<Item>
<text> abc </text>
<value> abc </value>
</Item>
<Item>
<text> efg </text>
<value> efg </value>
</Item>
</root>
</XML>mywork.xsl文件为:
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<select name="select" size="2" multiple="multiple">
<xsl:apply-templates select="//Item"/>
</select>
</html>
</xsl:template>
<xsl:template match="Item">
<option>
<xsl:attribute name="value">
<xsl:value-of select="value"/>
</xsl:attribute>
<xsl:value-of select="text"/>
</option>
</xsl:template>
</xsl:stylesheet>
解决方案 »
- HTML+JS读XML文件问题。
- safari怎么在后台注册的JS获取图片按钮的大小?
- js代码 IE提示缺少标识符 ff提示函数changeTableStyle is not defined (没有定义)
- 为什么用options.selectedIndex取下拉框的索引,只能得到-1?有哪些原因可能会导致这种情况??
- 没有人能实现网页文本相对于背景图片的精确定位吗?
- vbscript:如何获取后台数组的元素值啊
- 简单问题:怎么得到按键是否同时按了ctrl?
- javascrit 怎样取得 一个表单所有的 checkbox 的状态或值。
- 这个程序如何解释?(在线等)
- 跨框架操作问题。
- 如何在一个页面中刷新另一个页面
- 一个关于时间运算的问题,急!!!!!!
可是我学不会啊