积极答复者
xml简单的问题

问题
-
教材上是这么说的:
创建一个简单的index.xml文档:
< xml version="1.0" >
< xml-stylesheet type="text/xsl" href="basic.xsl" >
<basic>Hello World</basic>下面创建一个名为basic.xsl的XML样式表(XSL),以便在浏览器中显示XML文档内容:
< xml version="1.0" >
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>a basic stylesheet</title>
</head>
<body>
<xsl:value-of select="/" />
</body>
</html>
</xsl:template>
</xsl:stylesheet>接着在浏览器中打开index.xml文档,则可显示“Hello World”。
答案
-
<?xml version="1.0" ?> <?xml-stylesheet type="text/xsl" href="basic.xsl" ?> <basic>Hello World</basic>
<?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head> <title>a basic stylesheet</title> </head> <body> <xsl:value-of select="/" /> </body> </html> </xsl:template> </xsl:stylesheet>
- 已建议为答案 暗夜天使 2012年2月29日 6:13
- 已标记为答案 Honny_yeyh 2012年2月29日 9:06
全部回复
-
我按照教材上面的做,结果打开显示的是:
The XML page cannot be displayedCannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
Whitespace is not allowed at this location. Error processing resource 'file:///C:/Documents and Settings/u332744/Desktop/tt...
< xml version="1.0" > -^
- 已编辑 Honny_yeyh 2012年2月29日 4:58
-
<?xml version="1.0" ?> <?xml-stylesheet type="text/xsl" href="basic.xsl" ?> <basic>Hello World</basic>
<?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head> <title>a basic stylesheet</title> </head> <body> <xsl:value-of select="/" /> </body> </html> </xsl:template> </xsl:stylesheet>
- 已建议为答案 暗夜天使 2012年2月29日 6:13
- 已标记为答案 Honny_yeyh 2012年2月29日 9:06
-
谢谢楼上
的回复,不过还是提示错误:
<><>The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
Whitespace is not allowed at this location. Error processing resource 'file:///C:/Documents and Settings/u332744/Desktop/tt...
<? xml version="1.0" ?> --^
</> </>- 已编辑 Honny_yeyh 2012年2月29日 6:48
-
你好 为了更好的兼容以及控制 我们一般采用XSLT来对XML进行样式解析 在java或者C# 等强类型语言中都会有相应的类 在Js中可以创建相应的ActiveX对象进行解析
参考我这篇博客 http://kosmisch.net/archive/2009/09/28/4e6bea88471ba99ea4c27239.aspx
Raymond Tang (Microsoft C# MVP)
Denn Ich Gehoer nur mir
微软中文论坛同城社区成都QQ群:74268428
My Blog http://kosmisch.net
Chengdu,China