【发布时间】:2010-06-30 22:04:18
【问题描述】:
我有一个返回 XML 带有 xsl 样式表转换的网页,例如:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='/css/homepage.xsl'?>
<MyData>
...
</MyData>
它将转换后的 XSL 正确地显示为 HTML。但是当我尝试查看 XML 源代码时,Internet Explorer 给了我错误:
无法查看 XML 源文件
但我可以为您提供所需行为完美运行的网站 (Blizzards WoW Armory)(即您可以查看 xml 源):
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/_layout/pageIndex.xsl"?>
<page globalSearch="1" lang="es_mx" requestUrl="/index.xml" type="front">
<pageIndex>
<related-info/>
</pageIndex>
</page>
因此,“这种行为是设计使然”的论点被直接观察所反驳。
我的 XML 有什么问题,无法显示源 XML?
带你走错路
这里是一些补充信息。
来自暴雪(工作)站点的 Http 响应标头:
GET http://www.wowarmory.com/ HTTP/1.1
HTTP/1.1 200 OK
...
Content-Type: text/xml;charset=UTF-8
Content-Length: 233
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="/_layout/pageIndex.xsl"?><page globalSearch="1" lang="es_mx" requestUrl="/index.xml" type="front">
<pageIndex>
<related-info/>
</pageIndex>
</page>
这里是来自我的 (borken) xml 的响应标头:
GET http://www.example.com/default.ashx HTTP/1.1
HTTP/1.1 200 OK
...
Content-Type: text/xml; charset=utf-8
...
Content-Length: 131974
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='/css/homepage.xsl'?>
<MyData>
...
</MyData>
另见
【问题讨论】:
-
我不知道错误,但是例如(wowarmory.com/search.xml):即使文件扩展名是.xml,文件被提供为
text/html。 -
@digitalFresh 主页不是
.xml,我的主页也不是。
标签: xml http internet-explorer-8