RozanaZ
asked on
loadXML in FF
Hi Experts,
I have a problem with the following code. The problem is that code works in IE and doesn't work in FF.
Please advice.
Thanks in advance
<HTML>
<HEAD>
<TITLE></TITLE>
<script>
function getXMLDocument()
{
var xDoc=null;
if (document.implementation
&& document.implementation.cr eateDocume nt)
{
xDoc=document.implementati on.createD ocument("" ,"",null);
}
else if (typeof ActiveXObject != "undefined")
{
var msXmlAx=null;
try
{
msXmlAx=new ActiveXObject("Msxml2.DOMD ocument");
}
catch (e)
{
msXmlAx=new ActiveXObject("Msxml.DOMDo cument");
}
xDoc=msXmlAx;
}
if (xDoc==null || typeof xDoc.load=="undefined")
{
xDoc=null;
}
return xDoc;
}
var txt = "<ruleValues><rule_value>< value>v 1</value><name>value 1</name></rule_value><rule _value><va lue>v 2</value><name>value 2</name></rule_value></rul eValues>";
function test()
{
xmldoc = getXMLDocument();
//xmldoc.load("xml.xml");
xmldoc.loadXML(txt);
ruleValues = xmldoc.getElementsByTagNam e("ruleVal ues");
ruleValueNodes = ruleValues(0).childNodes;
for (i = 0; i < ruleValueNodes.length; i++)
{
valueNode = ruleValueNodes(i);
id = valueNode.childNodes(0).te xt;
value = valueNode.childNodes(1).te xt;
alert("ID: " + id + " value: " + value);
}
}
</script>
</HEAD>
<BODY>
<input type="button" value="Test" onClick="test()">
</BODY>
</HTML>
I have a problem with the following code. The problem is that code works in IE and doesn't work in FF.
Please advice.
Thanks in advance
<HTML>
<HEAD>
<TITLE></TITLE>
<script>
function getXMLDocument()
{
var xDoc=null;
if (document.implementation
&& document.implementation.cr
{
xDoc=document.implementati
}
else if (typeof ActiveXObject != "undefined")
{
var msXmlAx=null;
try
{
msXmlAx=new ActiveXObject("Msxml2.DOMD
}
catch (e)
{
msXmlAx=new ActiveXObject("Msxml.DOMDo
}
xDoc=msXmlAx;
}
if (xDoc==null || typeof xDoc.load=="undefined")
{
xDoc=null;
}
return xDoc;
}
var txt = "<ruleValues><rule_value><
function test()
{
xmldoc = getXMLDocument();
//xmldoc.load("xml.xml");
xmldoc.loadXML(txt);
ruleValues = xmldoc.getElementsByTagNam
ruleValueNodes = ruleValues(0).childNodes;
for (i = 0; i < ruleValueNodes.length; i++)
{
valueNode = ruleValueNodes(i);
id = valueNode.childNodes(0).te
value = valueNode.childNodes(1).te
alert("ID: " + id + " value: " + value);
}
}
</script>
</HEAD>
<BODY>
<input type="button" value="Test" onClick="test()">
</BODY>
</HTML>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Just perfect!
Thanks a lot!
Thanks a lot!
You're welcome!
Thanks for the A grade!
Suat
Thanks for the A grade!
Suat
http://www.webreference.com/programming/prof_ajax/3.html
Suat