下面就是简单的例子,这里提供2中方法:
test.htm
<script>
//装载数据
x = "<r><a name=27.net_lover'>aaaaaaaaaaa</a> <b>bbbbbbb</b><a>aaaaaaaaaaa</a><b>bbbbbbb</b></r>"
var source = new activexobject("msxml2.domdocument");
source.async = false;
source.loadxml(x)
alert(source.xml)
// 装载样式单
var stylesheet = new activexobject("msxml2.domdocument");
stylesheet.async = false;
stylesheet.resolveexternals = false;
stylesheet.load("style.xsl");
alert(stylesheet.xml)
// 创建结果对象
var result = new activexobject("msxml2.domdocument");
result.async = false;
// 把解析结果放到结果对象中方法1
source.transformnodetoobject(stylesheet, result);
alert(result.xml)
// 把解析结果放到结果对象中方法2
result2 = ""
result2 = source.transformnode(stylesheet);
source.loadxml(result2)
alert(source.xml)
</script>
style.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">
<xsl:output method = "xml" omit-xml-declaration = "yes" indent = "yes"/>
<xsl:template match="/ @* node()">
<xsl:copy>
<xsl:apply-templates select="@* node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器