Revising ASP.NET XML DataIsland Files

The mobile application I'm currently developing utilizes XML dataisland files for retrieving dropdown data. The snippet below showcases the code defining the file:

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

Here is an example code segment demonstrating the use of these XML dataislands:

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

This line involving oDataIsland is repeated around 4000 times throughout the application. Being an intranet-based app, I can prompt users to directly download the XML files. The main goal here is to minimize necessary adjustments while eliminating all XML tags. It's crucial that the application functions smoothly on Chrome upon completion.

I consulted a resource from mozilla regarding dataislands: https://developer.mozilla.org/en/docs/Using_XML_Data_Islands_in_Mozilla

Below you'll find a revised piece of code based on the information provided by mozilla:

var doc = document.getElementById(strDataSource).contentDocument;
var mainNode = doc.getElementsByTagName("DataIsland");
var oXmlNodes;
var strOptions = "";
for (i = 0; i < mainNode.length; i++) {
if (mainNode[i].getAttributeNode("ID").nodeValue == strDataMember) {
oXmlNodes = mainNode[i].getElementsByTagName("Option");
}
}

The code effectively gathers data and operates seamlessly in IE (10 with standard mode, no quirks). Implementing this change in the overall solution was relatively straightforward.

The only hiccup is that the

document.getElementById(strDataSource).contentDocument;
line encounters issues in Chrome. This property is undefined on Chrome despite being mentioned in Mozilla's documentation.

I'm seeking alternative suggestions to resolve this. I've attempted various methods such as using HTTPRequest (resulting in excessive requests per page), transitioning to JSON (which necessitates revamping existing methods entirely), or shifting XML processing to the backend instead of client-side (calling for architectural changes). Unfortunately, none of these approaches have yielded positive results so far.

Are there any other techniques I could explore? Or should I concentrate solely on rectifying the contentDocument conundrum?

Answer №1

In order to enable contentDocument access in Chrome, you will need to utilize the flag --allow-file-access-from-files. Here are the steps to follow:

  1. Locate the installation path of your Chrome browser (e.g., C:\Users-your-user-name\AppData\Local\Google\Chrome\Application)
  2. Open a command line window and launch Google Chrome with the additional argument '--allow-file-access-from-files'. For example: 'path-to-chrome-installation\chrome.exe --allow-file-access-from-files'
  3. If you want a temporary solution for testing purposes:
    • Duplicate the existing chrome launcher
    • Follow the above steps and save it under a new name like 'chrome-testing'
    • Alternatively, create a new launcher with the same settings to start Chrome.

Source

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Wait to fade in until the fade out process is completely finished

When I click on a button, the old box fades out and the new box fades in. However, I want to ensure that the .fadeIn() only happens once the .fadeOut() is complete. This will prevent two containers from being displayed simultaneously. Any suggestions on ...

In JavaScript, when all values are false in an object, the object's value should be set to False

My task involves working with a JSON data object that contains multiple key-value pairs. I need to determine whether at least one value is false and set another variable to "false" accordingly. Here is the JSON data that I am handling: var objectVal = re ...

Assigning a variable within a parent function from a child function in JavaScript

Struggling to assign the value of "result" in the inner function. Any suggestions on how to do this? I am able to console log the result variable inside the function, but a friend recommended using promises. However, I have no clue how to implement that ...

Cultural understanding of time [English and Arabic]

I am working with a date bound in an asp.net repeater control <%# Eval("PublishedDate") %> Within my application, I have support for two cultures: English and Arabic. Currently, the date appears as [29/04/35 07:00:00 م] in Arabic, but I would lik ...

Is HTML5 Device Orientation the answer to a dependable compass system?

I am currently developing a project for mobile web that requires access to the compass direction of the user's device. At the moment, my code is quite basic, but here is what I have: var updateDirection = function (evt) { $("#dire ...

SyntaxError: An unidentified item was encountered at the <head> location

I have encountered an issue while loading a PHP file that utilizes ajax. Initially, the page loads without any errors. However, upon triggering the onclick event on a button, I receive the error message "Uncaught SyntaxError: Unexpected identifier" pointin ...

What is the best way to switch between my two images upon clicking?

When I click on an image, it changes to a different image. I achieved this by altering the source of the image upon clicking. Now, my goal is to incorporate a smooth transition between the two images after they are clicked. I attempted to stack the two im ...

Use .load() to set an image as background in the div

There is a block of code that is supposed to display images in a div with the class "img", but it isn't functioning correctly. Can you provide some guidance on how to fix this issue? <div class="other"><a href="/index1.html">Link1</a&g ...

Strange problem with Mongoose and MongoDB arises while operating MEAN application on Openshift platform

My journey with Openshift has been quite eventful. From making drastic changes to learning about version-ing and nvm (Node Version Manager), it has been a rollercoaster ride. Dealing with npm versions to ensure compatibility with the server used express ve ...

HTML content that is produced through JSONP retrieval

Recently, I've been experimenting with the jQuery library and have found it to be quite useful. Lately, I've been delving into AJAX requests to fetch various information like weather updates, current downloads, and more, which has been going smoo ...

Utilizing Ajax to dynamically generate unique ID's for multiple checkboxes

I have been working on a website that is almost completed, however, I have come across a new task where I need to select check-boxes in order to archive news items or "blog posts". The concept is to have a check-box next to each blog post and by checking ...

Is it possible to replicate a stale closure similar to React's useEffect hook without the use of the useEffect hook?

I have a good understanding of closures, but I am struggling to grasp how a stale closure can be created in React's useEffect without providing an exhaustive dependencies array. In order to explore this concept further, I am attempting to replicate a ...

Issue with horizontal scroll bar losing position upon post back

I am currently troubleshooting an issue with a page that features a panel containing a horizontal scroll bar: <div id="pagingPanelDiv"> <asp:Panel ID="pagingPanel" runat="server" Height="50px" Width="1275px" ScrollBars="Horizontal" Wrap="fals ...

Apologies, we are experiencing a server error. TypeError: Unable to access the 'map' property of an undefined

I'm struggling to grasp the concept of fetching external data using server-side rendering with the getServerSideProps method. In particular, I am facing difficulties with the search functionality and how to handle the returned data. As someone who is ...

Folding without extending

My button has a div inside it with content. I've set it up so that when the div is clicked, the collapsed content expands. The hover effect changes color and pointer as expected. But for some reason, clicking on the div doesn't expand the content ...

Create labels and checkboxes within Visual Studio for every individual row retrieved from a database query

I need to create a label and checkbox for each row fetched from my query. While trying to determine the number of records returned by my SQL query, I encountered an issue with using int numberOfRecords = sqlCmd2.ExecuteNonQuery();. So, what alternative me ...

Video background in webflow not currently randomizing

I want to add a dynamic video background to my website created with Webflow. I attempted to achieve this using Javascript by including the following links: "https://s3.amazonaws.com/webflow-prod-assets/63e4f3713963c5649a7bb382/63f787b42f81b8648e70fed ...

Ways to keep the position of an expanded collapsible table from Material UI intact

I found a collapsible table code snippet on this website: https://mui.com/material-ui/react-table/#collapsible-table However, there seems to be an issue where when I expand a row, the table "grows up" as it increases in size. This behavior is not ideal. I ...

What is the best way to create a JSON string using JavaScript/jquery?

Is there a way to programmatically build a JSON string? The desired outcome should resemble the following: var myParamsJson = {first_name: "Bob", last_name: "Smith" }; Instead of constructing the entire object at once, I would prefer adding parameters one ...

Exploring the images in a continuous loop

Looking to create a unique image looping effect using HTML, CSS, and Jquery/Javascript. The concept is to display several images on one page that do not move, but loop through them one at a time while displaying text above the current image. For example, ...