在asp.net更换XML文件DataIsland [英] Replacing XML DataIsland Files in asp.net

查看:97
本文介绍了在asp.net更换XML文件DataIsland的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作的应用,目前使用XML文件dataisland检索下拉数据。下面是code定义文件。

The app I am working on, currently uses XML dataisland files to retrieve the dropdown data. Below is the code that defines the file.

    <xml id="DefaultDataIslands" src="../XMLData/DataIslands-<%=((User.Identity).Database)%>.xml">
    </xml>

下面是一个例子code使用这些XML dataislands。

Below is an example code that uses these XML dataislands.

var oDataIsland = document.getElementById("DefaultDataIslands");
var oXmlNodes = oDataIsland.XMLDocument.selectNodes("XMLDataIslands/DataIsland[@ID='DIMRGroup']/Option");

此oDataIsland行用于共约4K倍,在应用程序。应用程序本身是内网,所以,我甚至可以要求用户直接下载XML文件。整点是保持所需最低,同时去除XML标签的所有痕迹的变化。我想,以确保应用程序适用于Chrome一旦这件事情完成。

我查了一下,从Mozilla的关于这里的dataislands的链接。 https://developer.mozilla.org/en/docs/Using_XML_Data_Islands_in_Mozilla

I checked the link from mozilla regarding the dataislands here. https://developer.mozilla.org/en/docs/Using_XML_Data_Islands_in_Mozilla

下面是基于Mozilla的是链路上的code。

Below is the code based on that mozilla link.

    var doc = document.getElementById(strDataSource).contentDocument;
    var mainNode = doc.getElementsByTagName("DataIsland");
    var oXmlNodes;
    var strOptions = "";
    //finds the selected node based on the id, and gets the options for that id
    for (i = 0; i < mainNode.length; i++) {

        if (mainNode[i].getAttributeNode("ID").nodeValue == strDataMember) {
            oXmlNodes = mainNode[i].getElementsByTagName("Option");
        }
    }

这code读取数据正常,在IE浏览器(使用标准模式,无怪癖10)完美的作品,很容易改变足以在完整的解决方案做。

This code reads the data properly, works perfectly in IE (10 with standards mode, no quirks), was easy enough change to do in the full solution.

唯一的问题是,的document.getElementById(strDataSource).contentDocument; 线在Chrome中失败。这是在同一行发生了什么Mozilla的文件中提及。但不知何故, contentDocument 属性未定义的铬。

Only problem is, document.getElementById(strDataSource).contentDocument; line fails in Chrome. This is the same line as what was mentioned in Mozilla's documentation. But somehow contentDocument property is undefined on chrome.

所以,我需要如何得到这个修正了一些其他建议。我尝试过其他方法,使用HTT prequest(每页过多的要求),使用JSON(需要完全改变现有的方法),采用后端来处理XML,而不是做客户端(需要体系结构更改)。到现在为止,所有的这些想法失败了。

So, I need some other suggestion on how to get this fixed. I tried other methods, using HTTPRequest (too many request per page), using JSON (requires changing existing methods completely), using backend to process XML instead of doing it client side (requires architectural changes). Till now, all these ideas failed.

有,我可以用任何其他方法?或者我应该修正 contentDocument 问题?

Is there any other method that I can use? Or should I fix the contentDocument issue?

推荐答案

要允许 contentDocument 在Chrome中,你将不得不使用 - 允许-file访问 - 从 - 文件。以下是这样做的步骤:

To allow contentDocument in Chrome, you will have to use --allow-file-access-from-files. Following are the steps for doing so:


  1. 获取您的Chrome安装路径的URL到您的Chrome
    例如安装
    C:\\用户,您的用户名\\ AppData \\本地\\谷歌\\铬\\应用程序>

  2. 启动从与命令行窗口中的谷歌Chrome浏览器
    额外的参数'-ALLOW文件访问从 - 文件。例如路径
    您的Chrome安装\\的chrome.exe
    --allow-文件访问 - 从 - 文件

  3. 临时方法,你可以利用每次都是测试

    • 复制现有的Chrome启动

    • 如上做,用新的名称例如镀铬保存 - 测试

    • 另外,你可以简单地创建与上面一个新的启动,并用它来启动浏览器。

来源

这篇关于在asp.net更换XML文件DataIsland的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆