473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

loading xml file as string on firefox

I am trying to load xml file as well as xml as string input, and have written following code. This is working in IE but not in FireFox, can anyone help?


-------------------------------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. function MyXML() {
  2.  
  3. try{
  4. this._xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  5. this._flag = 1;
  6. }
  7. catch(e)
  8. {
  9. try{
  10.  
  11. this._xmlDoc=document.implementation.createDocumen t("","",null);
  12. this._flag = 2;
  13.  
  14. }catch(e) {alert(e.message);}
  15. }
  16.  
  17. }
  18.  
  19. MyXML.prototype._xmlDoc;
  20. MyXML.prototype._xmlObj;
  21. MyXML.prototype._firstElementText;
  22. MyXML.prototype._flag;
  23.  
  24.  
  25. MyXML.prototype.loadXMLFile = function(xmlFile)
  26. {
  27. try{
  28. this._xmlDoc.async="false";
  29. //this._xmlDoc.onreadystatechange=verify;
  30. this._xmlDoc.load(xmlFile);
  31. this._xmlObj=this._xmlDoc.documentElement;
  32. }catch(e) {alert(e.message)}
  33.  
  34. return this._xmlDoc;
  35. }
  36.  
  37. MyXML.prototype.loadXMLString = function(xmlString, document)
  38. {
  39. if(this._flag == 1)
  40. {
  41. try{
  42. this._xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  43. this._xmlDoc.async="false";
  44. this._xmlDoc.loadXML(xmlString);
  45. this._xmlObj=this._xmlDoc.documentElement;
  46. }catch(e) {alert(e.message)}
  47. }
  48. else if(this._flag == 2)
  49. {
  50. try{
  51. this._xmlDoc=document.implementation.createDocumen t("","",null);
  52. this._xmlDoc.async="false";
  53. var parser=new DOMParser();
  54. this._xmlDoc=parser.parseFromString(xmlString,"text/xml");
  55. //this._xmlObj=this._xmlDoc.documentElement;
  56. }catch(e) {alert(e.message)}
  57.  
  58. }
  59.  
  60. return this._xmlDoc;
  61. }
  62.  
---------------------------------------------------------------------------------------------------------------
Sep 17 '08 #1
1 1535
acoder
16,027 Expert Mod 8TB
This link may help. If not, do you get an error message in your code?
Sep 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Roy Wang | last post by:
hi, My problem is how to determining when the XML file has loaded using javascript. I loaded an xml file using javascript in a web page. The code below is loading the xml file for IE:...
17
by: CES | last post by:
All, I was wondering if their is a way of loading an external script fill from within a script?? <script language="javascript" type="text/javascript"> function test(var){ <script...
1
by: Richard | last post by:
I have a table that is about 100 rows long and within that table I have tons of links. The table takes about 2 seconds to load. I think javascript might help somehow. The problem is that in...
2
by: hbchai | last post by:
I'm adapting the ajax-like asynchronous request pattern mentioned in this article: http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-considered-harmful.html?page=2 for my Sudoku...
1
by: ozzy.osborn | last post by:
Hello All, I have been struggling with a cross browser solution to loading external javascript files on the fly. I have been successful using the following code in IE6: var newScr =...
2
by: nick.taylor | last post by:
Hi, I've been trying for weeks to figure out this problem. I'm developing a simple Javascript app that loads an XML file from a server, parses the contents, and displays them. But I am...
7
by: psybert | last post by:
Hello everyone, Long time lurker, first time poster. I'm a beginner coder, and I've taught myself everything with the help and expertise of users and websites like this one. I normally figure out...
6
by: Shigun | last post by:
On a website I am working on I am trying to load another page into a div on the the page the user does his work from. What I have works correctly in FireFox, but not in IE. I've rummaged Google for...
2
by: joe | last post by:
I am loading a text file to a variable with XMLHttpRequest() There seems to be some sort of timing issue since loadXML (source code below) returns the contents of the file on seconds try. In...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.