473,399 Members | 4,192 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,399 software developers and data experts.

loadXML from file and String problem on Firefox

I am new to JavaScript/XML, 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?
-------------------------------------------------------------------------------------------------------
function MyXML() {

try{
this._xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
this._flag = 1;
}
catch(e)
{
try{

this._xmlDoc=document.implementation.createDocumen t("","",null);
this._flag = 2;

}catch(e) {alert(e.message);}
}

}

MyXML.prototype._xmlDoc;
MyXML.prototype._xmlObj;
MyXML.prototype._firstElementText;
MyXML.prototype._flag;


MyXML.prototype.loadXMLFile = function(xmlFile)
{
try{
this._xmlDoc.async="false";
//this._xmlDoc.onreadystatechange=verify;
this._xmlDoc.load(xmlFile);
this._xmlObj=this._xmlDoc.documentElement;
}catch(e) {alert(e.message)}

return this._xmlDoc;
}

MyXML.prototype.loadXMLString = function(xmlString, document)
{
if(this._flag == 1)
{
try{
this._xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
this._xmlDoc.async="false";
this._xmlDoc.loadXML(xmlString);
this._xmlObj=this._xmlDoc.documentElement;
}catch(e) {alert(e.message)}
}
else if(this._flag == 2)
{
try{
this._xmlDoc=document.implementation.createDocumen t("","",null);
this._xmlDoc.async="false";
var parser=new DOMParser();
this._xmlDoc=parser.parseFromString(xmlString,"tex t/xml");
//this._xmlObj=this._xmlDoc.documentElement;
}catch(e) {alert(e.message)}

}

return this._xmlDoc;
}

---------------------------------------------------------------------------------------------------------------
Sep 16 '08 #1
0 2918

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

Similar topics

1
by: KathyB | last post by:
I've discovered I need to use LoadXML instead of Load for an xml string versus an xml file. HOWEVER, I get the above message when .net goes to load the string. The string comes from an...
3
by: AFN | last post by:
I'm comfortable with VB.NET but new to XML. I am getting XML data from a remote machine across the internet. Sometimes my LoadXML call works fine and I parse out the data I need thereafter. ...
6
by: jmgonet | last post by:
Hello everybody, I'm having troubles loading a Xml string encoded in UTF-8. If I try this code: ------------------------------ XmlDocument doc=new XmlDocument(); String s="<?xml...
4
by: cloudx | last post by:
hi there, in VB LoadXML(str) returns true or false so that you can do different coding when the str is XML or not, but in C# LoadXML doesn't have return but only throw exception if str is not XML...
0
by: Reshma Prabhu | last post by:
Hello, I am using XmlDataDocument's LoadXml( ) function to load a particular xml string. This xml string contains a reference to a particular DTD. Though LoadXml function does not perform DTD or...
2
by: Lupina | last post by:
Hi I want load whole xml file, I try do it in the same way as I did it in windows application. try { XmlDocument myDoc = new XmlDocument();
25
by: MeNotHome | last post by:
I am automating the navigation of a website. When I reach the end, it changes to xml. So my axwebbrowser1 has a bunch of xml data in it. So here is what I am trying to do Dim xmlText As...
2
by: binder | last post by:
How do I eliminate an extra backslash that is appearing after LoadXML call? This issue is causing an error with Process.Start. I have a string stored in sql: c:\program files\internet...
1
by: Beamor | last post by:
function art_menu_xml_parcer($content, $showSubMenus) { $doc = new DOMDocument(); $doc->loadXML($content);//this is the line in question $parent = $doc->documentElement; $elements =...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.