网页中无法显示XML文件内容。XML文件命名为employee,和htm文件保存在同一个文件夹里。
<html><head><title>显示XML元素和属性</title></head><body><xmlid="xmldata"scr="employee.xml">...
<html>
<head>
<title>显示XML元素和属性</title>
</head>
<body>
<xml id="xmldata" scr="employee.xml"></xml>
<h1 align="center">职工基本信息</h1>
<table datasrc="#xmldata" border="1" align="center" cellpadding="3">
<thead>
<th><span>职工编号</span></th>
<td><span>姓名</span></td>
<td><span>职称</span></td>
<td><span>性别</span></td>
<td><span>部门</span></td>
<td><span>联系电话</span></td>
</thead>
<tr>
<td><span datafld="职工编号"></span></td>
<td>
<table datasrc="#xmldata" datafld="姓名"><tr><td><span datafld="$text"></span></td></tr></table>
<td>
<table datasrc="#xmldata" datafld="姓名"><tr><td><span datafld="职称"></span></td></tr></table>
</td>
<td><span datafld="性别"></span></td>
<td><span datafld="部门"></span></td>
<td><span datafld="联系电话"></span></td>
</tr>
</table>
</body>
</html>
结果只显示这些 展开
<head>
<title>显示XML元素和属性</title>
</head>
<body>
<xml id="xmldata" scr="employee.xml"></xml>
<h1 align="center">职工基本信息</h1>
<table datasrc="#xmldata" border="1" align="center" cellpadding="3">
<thead>
<th><span>职工编号</span></th>
<td><span>姓名</span></td>
<td><span>职称</span></td>
<td><span>性别</span></td>
<td><span>部门</span></td>
<td><span>联系电话</span></td>
</thead>
<tr>
<td><span datafld="职工编号"></span></td>
<td>
<table datasrc="#xmldata" datafld="姓名"><tr><td><span datafld="$text"></span></td></tr></table>
<td>
<table datasrc="#xmldata" datafld="姓名"><tr><td><span datafld="职称"></span></td></tr></table>
</td>
<td><span datafld="性别"></span></td>
<td><span datafld="部门"></span></td>
<td><span datafld="联系电话"></span></td>
</tr>
</table>
</body>
</html>
结果只显示这些 展开
1个回答
展开全部
<?xml version="1.0"?>
<!-- File Name: book.xsl -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<h2 align="center">BookInformation</h2>
<table border="1" cellpadding="7" align="center" bgcolor="#00EE00">
<xsl:for-each select="bookinfo/book" >
<tr>
<td><SPAN STYLE="font-weight:bold font-size:10">BookiId: </SPAN></td>
<td><SPAN STYLE="font-style:italic font-size:10">Bookcategory: </SPAN> </td>
<td><SPAN STYLE="font-style:italic font-size:10">BookAmount: </SPAN> </td>
<td><SPAN STYLE="font-style:italic font-size:10">BookRemain: </SPAN> </td>
<td><SPAN STYLE="font-style:italic font-size:10">Bookdiscount: </SPAN> </td>
<td><SPAN STYLE="font-style:italic font-size:10">Title: </SPAN> </td>
<td><SPAN STYLE="font-style:italic font-size:10">Author: </SPAN> </td>
<td><SPAN STYLE="font-style:italic font-size:10">Publisherxt: </SPAN> </td>
<td><SPAN STYLE="font-style:italic font-size:10">Price: </SPAN> </td>
<td><SPAN STYLE="font-style:italic font-size:10">ISBN: </SPAN> </td>
</tr>
<tr>
<td><xsl:value-of select="@id"/><BR /></td>
<td><xsl:value-of select="@bookcategory"/><BR /></td>
<td><xsl:value-of select="@amount"/><BR /></td>
<td><xsl:value-of select="@remain"/><BR /></td>
<td><xsl:value-of select="@discount"/><BR /></td>
<td><xsl:value-of select="title"/><BR /></td>
<td><xsl:value-of select="author"/><BR /></td>
<td><xsl:value-of select="publisher"/><BR /></td>
<td><xsl:value-of select="price"/><BR /></td>
<td><xsl:value-of select="ISBN"/><BR /></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
楼主在XML中链接了一个book.xsl的文档,所以想必是想用xsl在IE中来显示xml文档内容吧。你把我写的这个命名为book.xsl 跟你的那个xml文档放在一个文件夹里面,然后双击xml文档打开它,就可以显示其内容,而且是以表格的形式显示出来。另外,你的文档里面有中文,把顶头那个声明改成<?xml version="1.0" encoding="GBK"?>吧。
<!-- File Name: book.xsl -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<h2 align="center">BookInformation</h2>
<table border="1" cellpadding="7" align="center" bgcolor="#00EE00">
<xsl:for-each select="bookinfo/book" >
<tr>
<td><SPAN STYLE="font-weight:bold font-size:10">BookiId: </SPAN></td>
<td><SPAN STYLE="font-style:italic font-size:10">Bookcategory: </SPAN> </td>
<td><SPAN STYLE="font-style:italic font-size:10">BookAmount: </SPAN> </td>
<td><SPAN STYLE="font-style:italic font-size:10">BookRemain: </SPAN> </td>
<td><SPAN STYLE="font-style:italic font-size:10">Bookdiscount: </SPAN> </td>
<td><SPAN STYLE="font-style:italic font-size:10">Title: </SPAN> </td>
<td><SPAN STYLE="font-style:italic font-size:10">Author: </SPAN> </td>
<td><SPAN STYLE="font-style:italic font-size:10">Publisherxt: </SPAN> </td>
<td><SPAN STYLE="font-style:italic font-size:10">Price: </SPAN> </td>
<td><SPAN STYLE="font-style:italic font-size:10">ISBN: </SPAN> </td>
</tr>
<tr>
<td><xsl:value-of select="@id"/><BR /></td>
<td><xsl:value-of select="@bookcategory"/><BR /></td>
<td><xsl:value-of select="@amount"/><BR /></td>
<td><xsl:value-of select="@remain"/><BR /></td>
<td><xsl:value-of select="@discount"/><BR /></td>
<td><xsl:value-of select="title"/><BR /></td>
<td><xsl:value-of select="author"/><BR /></td>
<td><xsl:value-of select="publisher"/><BR /></td>
<td><xsl:value-of select="price"/><BR /></td>
<td><xsl:value-of select="ISBN"/><BR /></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
楼主在XML中链接了一个book.xsl的文档,所以想必是想用xsl在IE中来显示xml文档内容吧。你把我写的这个命名为book.xsl 跟你的那个xml文档放在一个文件夹里面,然后双击xml文档打开它,就可以显示其内容,而且是以表格的形式显示出来。另外,你的文档里面有中文,把顶头那个声明改成<?xml version="1.0" encoding="GBK"?>吧。
追问
没有啊,只是想用htm文档来显示xml的,按照你那个说法,我是不是需要把xml里面的代码重新改一下。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询