[jQuery] XML processing in Firefox 3 and IE7 using jQuery

[jQuery] XML processing in Firefox 3 and IE7 using jQuery


I use following code to process the XML I get from server and populate
we page using it.
function loadProcessInfo() {
try {
var response = ProcessManagementService.listAllProcesses();
var processInfoList = $(response).find('process-info-list');
populateData(processInfoList);
} catch(e) {
if (typeof(e) == "string") {
alert("Exception occured:\n" + e.toString());
} else
{
alert("Exception occurred!");
}
}
}
function populateData(processInfoList) {
var contentHTML = '<h2>Currently Deployed Processes</h2>';
var activeInstances = 0;
var completedInstances = 0;
var errorInstances = 0;
var failedInstances = 0;
var suspendedInstances = 0;
var terminatedInstances = 0;
$(processInfoList).find('process-info').each(function(index) {
var pid = $(this).find('pid').text();
var version = $(this).find('version').text();
var status = $(this).find('status').text();
var depDate = $(this).find('deployment-info').find('deploy-
date').text();
var len = pid.length;
var endPos = pid.indexOf('}');
var startPos = pid.indexOf('{');
var nameWithVersion = pid.substr(++endPos, len);
var processName = $(this).find('definition-
info').find('process-name').text();
var indexOfColon = processName.indexOf(':');
var prefixOfName = processName.substring(0, indexOfColon);
var urlOfName = pid.substr(++startPos, (endPos - 2));
$(this).find('instance-
summary').children().each(function(index) {
if ($(this).attr('state') == 'ACTIVE') {
activeInstances = parseInt($(this).attr('count'));
} else if ($(this).attr('state') == 'COMPLETED') {
completedInstances = parseInt($(this).attr('count'));
} else if ($(this).attr('state') == 'ERROR') {
errorInstances = parseInt($(this).attr('count'));
} else if ($(this).attr('state') == 'FAILED') {
failedInstances = parseInt($(this).attr('count'));
} else if ($(this).attr('state') == 'SUSPENDED') {
suspendedInstances = parseInt($(this).attr('count'));
} else if ($(this).attr('state') == 'TERMINATED') {
terminatedInstances = parseInt($(this).attr('count'));
}
});
contentHTML += '<div class="process">' +
'<div class="processheader">' +
'<h3><img src="images/process.png"/>' + pid +
'</h3>' +
'</div>' +
'<div class="main_details">' +
'<span class="clearboth"></span>' +
'<table><tr><td class="alt"> Process Summary</
td></tr><tr><th>' +
'Deploy Date:</th><td>' + depDate + '</
td><th>Status:</th><td>' +
status + '</td><th>Version:</th><td>' +
version + '</td></tr>' +
'<table><tr><td class="alt"> Instance Summary</
td></tr><tr><th>Active:</th><td>' +
activeInstances + '</td><th>Terminated:</
th><td>' +
terminatedInstances + '</td><th>Completed:</
th><td>' +
completedInstances + '</td><th>Error:</th><td>'
+
errorInstances + '</td><th>Failed:</th><td>' +
failedInstances + '</td><th>Suspended:</
th><td>' +
suspendedInstances + '</td> </tr><tr><td>' +
'<a class="button" onclick=retireProcess("' +
nameWithVersion + '","' + urlOfName + '","' + prefixOfName +
'")><span>Retire</span></a>' +
'<a class="button" onclick=activateProcess("' +
nameWithVersion + '","' + urlOfName + '","' + prefixOfName +
'")><span>Activate</span></a></td></tr> </
table></table></div></div>';
});
$('#content').html(contentHTML);
}
And here is a example XML file.
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
envelope/">
<soapenv:Body>
<axis2ns8:listAllProcessesResponse xmlns:axis2ns8="http://
www.apache.org/ode/pmapi">
<process-info-list>
<ns:process-info xmlns:ns="http://www.apache.org/ode/
pmapi/types/2006/08/02/">
<ns:pid>{http://ode/bpel/unit-test}HelloWorld2-3</
ns:pid>
<ns:status>ACTIVE</ns:status>
<ns:version>3
</ns:version>
<ns:definition-info>
<ns:process-name xmlns:unit="http://ode/bpel/
unit-test">unit:HelloWorld2
</ns:process-name>
</ns:definition-info>
<ns:deployment-info>
<ns:package>HelloWorld2</ns:package>
<ns:document>HelloWorld2.bpel
</ns:document>
<ns:deploy-date>2008-06-15T17:52:04.523+05:30</
ns:deploy-date>
</ns:deployment-info>
<ns:instance-summary>
<ns:instances state="ACTIVE" count="0"/>
<ns:instances state="COMPLETED" count="0"/>
<ns:instances state="ERROR" count="0"/>
<ns:instances state="FAILED" count="0"/>
<ns:instances state="SUSPENDED" count="0"/>
<ns:instances state="TERMINATED" count="0"/>
</ns:instance-summary>
<ns:properties />
<ns:endpoints/>
<ns:documents>
<ns:document>
<ns:name>HelloWorld2.bpel</ns:name>
<ns:type>http://schemas.xmlsoap.org/ws/
2004/03/business-process/
</ns:type>
<ns:source>file:/home/milinda/programs/
apache-tomcat-5.5.26/webapps/ode/WEB-INF/processes/HelloWorld2/
HelloWorld2.bpel
</ns:source>
</ns:document>
<ns:document>
<ns:name>HelloWorld2.wsdl</ns:name>
<ns:type>http://schemas.xmlsoap.org/wsdl/</
ns:type>
<ns:source>
file:/home/milinda/programs/apache-
tomcat-5.5.26/webapps/ode/WEB-INF/processes/HelloWorld2/
HelloWorld2.wsdl
</ns:source>
</ns:document>
<ns:document>
<ns:name>HelloWorld2.cbp</ns:name>
<ns:type>http://www.fivesight.com/schemas/
2005/12/19/CompiledBPEL
</ns:type>
<ns:source>file:/home/milinda/programs/
apache-tomcat-5.5.26/webapps/ode/WEB-INF/processes/HelloWorld2/
HelloWorld2.cbp
</ns:source>
</ns:document>
</ns:documents>
</ns:process-info>
<ns:process-info xmlns:ns="http://www.apache.org/ode/
pmapi/types/2006/08/02/">
<ns:pid>{http://example.com/bpel/
counter}counter-1</ns:pid>
<ns:status>ACTIVE</ns:status>
<ns
:version>1
</ns:version>
<ns:definition-info>
<ns:process-name xmlns:coun="http://example.com/
bpel/counter">coun:counter
</ns:process-name>
</ns:definition-info>
<ns:deployment-info>
<ns:package>counter
</ns:package
>
<ns:document>counter.bpel</ns:document>
<ns:deploy-date>2008-06-15T15:12:06.348+05:30
</ns:deploy-date
>
</ns:deployment-info>
<ns:instance-summary>
<ns:instances state="ACTIVE" count="0"/>
<ns:instances state
="COMPLETED" count="0"/>
<ns:instances state="ERROR" count="0"/>
<ns:instances state="FAILED" count="0"
/>
<ns:instances state="SUSPENDED" count="0"/>
<ns:instances state="TERMINATED" count="0"/>
</ns:instance-summary
>
<ns:properties/>
<ns:endpoints/>
<ns:documents>
<ns:document>
<ns:name>counter.wsdl</ns:name>
<ns:type>http://schemas.xmlsoap.org/wsdl/
</ns:type>
<ns:source>file:/home/milinda/programs/apache-
tomcat-5.5.26/webapps/ode/WEB-INF/processes/counter/counter.wsdl
</ns:source>
</ns:document>
<ns:document>
<ns:name>counter.cbp
</ns:name>
<ns:type>http://www.fivesight.com/schemas/
2005/12/19/CompiledBPEL</ns:type>
<ns:source>file:/home/milinda/programs/apache-
tomcat-5.5.26/webapps/ode/WEB-INF/processes/counter/counter.cbp
</ns:source>
</ns:document>
<ns:document>
<ns:name>counter.bpel</ns:name>
<ns:type>http://schemas.xmlsoap.org/ws/2004/03/
business-process/
</ns:type>
<ns:source>file:/home/milinda/programs/apache-
tomcat-5.5.26/webapps/ode/WEB-INF/processes/counter/counter.bpel
</ns:source>
</ns:document>
</ns:documents>
</ns:process-info>
</process-info-list>
</axis2ns8:listAllProcessesResponse>
</soapenv:Body>
</soapenv:Envelope>
Previous code work well with Firefox 2 and but didn't work with
Firefox 3 and IE 7.
Can anyone tell me what is the problem with my code and why that code
not work in firefox 3. I think that namespaces in xml elements cause
this problem. getElementsByTagName didn't work with firefox 3 when we
have namespaces in XML elements. And getElementsByTagNameNS behave
differently in IE and Firefox 3. Did jQuery provide a solution for
these problems.
Thanks in advance,
Milinda