初学者求教XML问题!
我的XML文档如下:
<?xml version= "1.0 " encoding= "gb2312 " ?>
- <Root Description= "用户套房 " MemberID= "2757 " UserName= "command " Sex= "男 " State= "0 " LastUpdate= "4/17/2007 1:04:44 PM ">
- <Room>
<RoomName RoomID= "房间1 "> 房间1 </RoomName>
<RoomName RoomID= "房间2 "> 房间2 </RoomName>
<RoomName RoomID= "房间3 "> 房间3 </RoomName>
</Room>
- <Item Description= "用户套房信息 ">
- <HouseInfo>
<HouseID> 1732 </HouseID>
<HouseName> command的套房 </HouseName>
<HouseType> 10 </HouseType>
<HouseImg> /Images/Shop/User/defaultManBody.gif </HouseImg>
<Visited> 9 </Visited>
<Members> 1 </Members>
</HouseInfo>
</Item>
- <Item Description= "成员信息 ">
- <MemberInfo>
- <Data>
<MemberID> 2757 </MemberID>
<UserName> command </UserName>
<Sex> 男 </Sex>
</Data>
</MemberInfo>
</Item>
- <Item Description= "拜访信息 ">
<VisitMessage />
</Item>
</Root>
我在XLS样式表里想在一个写一个select下来菜单让用户选择-
<Room>
<RoomName RoomID= "房间1 "> 房间1 </RoomName>
<RoomName RoomID= "房间2 "> 房间2 </RoomName>
<RoomName RoomID= "房间3 "> 房间3 </RoomName>
</Room>
里面每一个RoomName子元素的值,应该怎么写.
我是这样写的
<td width= "16% "> <select name= "select ">
<xsl:for-each select= "Room/RoomName ">
<option> <xsl:value-of select= "Room/RoomName " /> </option>
</xsl:for-each>
</select> </td>
为什么我的下拉菜单里面没有内容,是空白的,但是有3个选项在里面,只是内容是空白
[解决办法]
<option>
<xsl:attribute name= "value ">
<xsl:value-of select= "Room/RoomName " />
</xsl:attribute>
[解决办法]
怎么又有?
<xsl:for-each select= "Root/Room/*>
</xsl:for-each>
*表示指定节点下的所有节点
.表示当前节点,等同于current()
楼上的应该解决不了问题
如果为给option的value增加值,才需要用到 <xsl:attribute name= "value ">
[解决办法]
<option> <xsl:value-of select= "Room/RoomName " /> </option>
改成
<option> <xsl:value-of select= ". " /> </option>
其他不变