欢迎光临极品网,更多、更新的资源信息尽在Jpinw.Com!本站所有信息资源每日更新新的内容,请大家继续关注www.Jpinw.com!如果觉得本站还不错,对您有帮助,别忘了向您的朋友推荐本站!请记好本站网址:http://www.Jpinw.com,网站发展靠大家多多的支持!!!

极品网 极品课件 极品论文 极品文学 极品游戏 极品美容 极品手机资源 极品股票

#
免费资源: 免费域名 | 免费空间 | 免费推广 | 免费邮箱 | 免费硬盘 | 免费论坛 | 免费留言 | 免费统计 | 在线投稿 | 更多...
电脑学院: 操作系统 | 安全相关 | 网页设计 | 编程开发 | 建站经验 | 服务器类 | 黑客攻防 | 菜鸟入门 | 教你网赚 | 更多...
文章导航: 网赚学堂 | 网赚秘笈 | 网赚三维 | 网赚先锋 | 网赚资讯 | 感悟网赚 | 众生百态 | 经典美文 | 范文中心 | 更多...
图酷天下: 时事图酷 | 娱乐图酷 | 搞笑图酷 | 时尚图酷 | 体育图酷 | 另类经典 | 论文资源 | 课件下载 | 文学知识 | 更多...

您现在的位置: 极品网 >> 电脑学院 >> 编程开发 >> XML >> 教程正文

建立MSXML 测试环境          【字体:
建立MSXML 测试环境
作者:佚名    教程来源:不详    点击数:    更新时间:2006-6-5    

 








    一般的Windows环境(Windows 98 SE以上版本)都有一个MSXML环境,以下的asp代码可以运行,但不一定工作,不工作可能是由于样式单是http://www.w3.org/1999/XSL/Transform的,而最初环境只支持http://www.w3.org/TR/WD-xsl,所以可能什么也不出来。

<%@ LANGUAGE = JScript %>
<%
// Set the source and style sheet locations here
var sourceFile = Server.MapPath("test.xml");
var styleFile = Server.MapPath("test.xsl");

// Load the XML
var source = Server.CreateObject("Microsoft.XMLDOM");
source.async = false;
source.load(sourceFile);
// Load the XSL
var style = Server.CreateObject("Microsoft.XMLDOM");
style.async = false;
style.load(styleFile);
Response.Write(source.transformNode(style));
%>

一般以MSXML为开发环境的都要建立安装新的解析器,如MSXML 3或者MSXML 4 Technology Preview,
在以replace方式装了MSXML 3后,我们可以使用以下的代码

<%@ LANGUAGE = JScript %>
<%
// Set the source and style sheet locations here
var sourceFile = Server.MapPath("test.xml");
var styleFile = Server.MapPath("test.xsl");

// Load the XML
var source = Server.CreateObject("Msxml2.DOMDocument");
source.async = false;
source.load(sourceFile);
// Load the XSL
var style = Server.CreateObject("Msxml2.DOMDocument");
style.async = false;
style.load(styleFile);
Response.Write(source.transformNode(style));
%>

这样我们获得了MSXML 3的开发环境,但如果我们不想破坏原来的环境,又要测试我们基于MSXML 3的例子呢,虽然用replace方式安装提供了向后兼容方式来支持XSL元素,函数和XSL命名空间。

其实使用版本无关progIDs(version-dependent progIDs)来创建对象实例可以更好的完成工作,我们不需要用replace方式安装,用side-by-side方式即可,我们看下面的代码:

<%@ LANGUAGE = JScript %>
<%
// Set the source and style sheet locations here
var sourceFile = Server.MapPath("test.xml");
var styleFile = Server.MapPath("test.xsl");

// Load the XML
var source = Server.CreateObject("Msxml2.DOMDocument.3.0");
source.async = false;
source.load(sourceFile);
// Load the XSL
var style = Server.CreateObject("Msxml2.DOMDocument.3.0");
style.async = false;
style.load(styleFile);
Response.Write(source.transformNode(style));
%>

只需要在Msxml2.DOMDocument后面加上版本号3.0,即可使用MSXML 3的东东了,MSXML 4呢,依次类推。

在客户端的环境也是一样的,用js创建DOM对象是一样的。

function test(){
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var currNode;
xmlDoc.async = false;
xmlDoc.load("test.xml");
currNode = xmlDoc.documentElement.firstChild;
alert(currNode.xml);
}

最后,XSLT样式单side-by-side方式下在Internet Explorer 5.0及以后版本不支持。如果你要使用IE 5来打开XSLT样式单,需要用replace方式安装。


  
网上收集

 

教程录入:dping    责任编辑:dping 
  • 上一篇教程:

  • 下一篇教程:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关教程
    Windows XP教程《XP:学用脚
    微星MS-8850按了复位键后,不
    遇到16位 MS-DOS子系统的错误
    电脑好像中毒了 重起机 连CO
    得到WEBSHELL,如何能得到所
    为什么系统自动更新以后就出
    C:WINDOWS\systen32\msibm\z
    组策略找不到怎么办?在运行
    mschk.exe是什么东西
    打不开子网页 修复时老是说“
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    极品网
    | 设为首页 | 加入收藏 | 友情链接 | 版权声明 |
    极品网

    Copyright 2006 Jpinw.com 极品网

    备案号:申请中

    极品网