www.webdeveloper.com
Results 1 to 2 of 2

Thread: XML in chrome

Hybrid View

  1. #1
    Join Date
    Oct 2011
    Posts
    2

    XML in chrome

    So i have this code that loads data from an xml into a table depending on what someone searches. It works in firefox and IE, not sure about safari, but not at all in chrome. Is there something I should change in it to make it work in chrome. Any help is appreciated.

    Code:
    window.onload = loadIndex;
    
    function loadIndex() { // load indexfile
    // most current browsers support document.implementation
    	if (document.implementation && document.implementation.createDocument) {
    		xmlDoc = document.implementation.createDocument("", "", null);
    		xmlDoc.load("wdparts.xml");
    	}
    // MSIE uses ActiveX
    	else if (window.ActiveXObject) {
    		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    		xmlDoc.async = "false";
    		xmlDoc.load("wdparts.xml");
    	}
    }
    
    
    
    function searchIndex() { 
    	if (!xmlDoc) {
    		loadIndex();
    	}
    	// get the search term from a form field with id 'searchme'
    
    	var searchterm = document.getElementById("searchme").value;
    	var searchtype = getType();
    	var allitems = xmlDoc.getElementsByTagName("item");
    	results = new Array;
    	if (searchterm.length < 3) {
    		alert("Enter at least three characters");
    	} 
    	else {
    // see if the XML entry matches the search term,
    // and (if so) store it in an array		\
    		for (var i=0;i<allitems.length;i++) {
    			var name = allitems[i].getAttribute(searchtype);
    			var exp = new RegExp(searchterm,"i");
    			if ( name.match(exp) != null) {
    				results.push(allitems[i]);
    			}
    		}
    // send the results to another function that displays them to the user
    	showResults(results, searchterm);
    	}
    }

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    maybe this:
    Code:
    results = new Array;
    Should be:
    Code:
    results = new Array();
    // or even simpler
    results=[];

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles