发送XML内容前,先发送header.header("Content-type: text/xml");
解决方案 »
- Thinkphp的ajax提交的问题
- 操作的时候经常出现Can not connect to MySQL server,刷新下就好了
- 为什么程序运行后文件无法上载?
- php xajxa的兼容性问题?
- 在模板中,例如smarty和smartTemplate,在编辑数据的时候,怎么对select的selected做设定?
- 发现了一个问题不知道怎么解决???是关于php pdf函数 pdf_set_info
- 高手帮忙查一个源码问题。我想了几天都查不出有什么问题。
- 怎样刷新母窗口
- 那儿有php的新闻小偷源程序啊?
- 关于COOKIE的调用,为什么调用时还得进行刷新才可得到传给COOKIE的传,我要真接得到值,求大侠们帮忙!!
- 谁知道如何用PHP操作XML?
- 晕~!死,看你们怎么办 ,在线等~!
========================================
menu.php文件:
<?php
header("Content-Type: text/xml");
echo "<?xml version='1.0' encoding='gb2312' ?>\n";
echo "<?xml-stylesheet type='text/xsl' href='menu_xsl.php' ?>\n";
?>
<root href="preview.php" image="" value="ONE">
<topmenu href="allset.php" image="" value="ONE_ONE">
<menu href="status.php" image="">ONE_ONE_ONE</menu>
<menu href="file_man.php" image="">ONE_ONE_TWO</menu>
<menu href="select_tpl.php" image="">ONE_ONE_THREE</menu>
</topmenu> <topmenu href="" image="" value="后台" /> <topmenu href="exit.php" image="" value="EXIT" />
</root>------------------------------------------
menu_xsl.php文件:
<?php
header("Content-Type: text/xml");
echo "<?xml version='1.0' encoding='gb2312' ?>\n";
?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<STYLE TYPE="text/css" TITLE="">
TABLE{
background-color:#fffaf0;
border-width : 1px 1px 1px 1px;
}
TD{
color:#0000ff;
height:18;
font-size:12px;
}
A{
color: #000033;
text-decoration: none;
}
A:VISITED{
color: #000055;
text-decoration: none;
}
A:HOVER{
text-decoration: underline;
color:#ff0000;
}
A:ACTIVE{
color: #0000ff;
text-decoration: underline;
} </STYLE>
<body>
<table border="0" cellspacing="1" cellpadding="0" width="300">
<tr>
<td ></td>
<td >名称</td>
<td >链接</td>
</tr>
<tr><td colspan="3"><font color="red">网站名称</font>
<xsl:for-each select="root">
<xsl:value-of select="@value"/>
</xsl:for-each>
</td>
</tr>
<xsl:for-each select="root/topmenu">
<tr>
<td colspan="3">
<xsl:value-of select="@value" />
</td>
</tr>
<xsl:for-each select="menu">
<tr>
<td width="23"></td>
<td>
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="@href" /></xsl:attribute>
<xsl:value-of select="." />
</xsl:element>
</td>
<td style="color:red;font-style:italic;">
<xsl:value-of select="@href" />
</td>
</tr>
</xsl:for-each>
</xsl:for-each>
<tr><td colspan='2' ><hr /></td>
<td>
<script language="JavaScript">
<xsl:comment>
tmpDate = new Date();
date = tmpDate.getDate();
month= tmpDate.getMonth() + 1 ;
year= tmpDate.getYear();
document.write(year);
document.write(".");
document.write(month);
document.write(".");
document.write(date);
</xsl:comment>
</script>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
同样,在输出内容前,要加上 header("Content-Type: text/xml");
但是 我试了 还是出现我说的第2种情况 (要刷新才能看得见)
不知道服务器端要不要做什么配置呢?
一般的WEB服务器中默认已定义.如果已定义.
先看看你的代码?
地址:
http://xingtai.51.net/netvt/menu.php我这里测试没问题 IE 6.0.2800.1106 SP1
现在我意识到另外一个问题
好象这样做没有什么意义
不知道我用数据库储藏数据
又想赶赶潮流 想试一下XML 有什么好的解决方案吗?
Mozilla对ms标准的xsl支持不太好!