I've encountered an issue with ajax and xml. I have an xml file that contains the status of multiple buttons. In my webpage, I need to determine the current status of each button. Here's a snippet from the xml file:
<?xml version="1.0" encoding="utf-8"?>
<btn_status>
<btn1>
<titel>Button 1</titel>
<status>inactive</status>
</btn1>
<btn2>
<titel>Button 2</titel>
<status>active</status>
</btn2>
</btn_status>
Here is a portion of my ajax script:
document.write("<p>Button Status</p>");
document.write("<table border='1'>");
var xmlContent=xmlDoc.getElementsByTagName("btn1");
for (i=0;i<xmlContent.length;i++)
{
document.write("<tr><td>");
document.write(xmlContent[i].getElementsByTagName("titel")[0].childNodes[0].nodeValue);
document.write("</td><td>");
document.write(xmlContent[i].getElementsByTagName("status")[0].childNodes[0].nodeValue );
if(btnStatus1=xmlDoc.getElementsByTagName("status")[0].childNodes[0].nodeValue == 'active'){
document.write("<img src='Normal.png' />");
}
else // ie5/6
{
document.write("<img src='error.png' />");
}
document.write("</td></tr>");
}
The challenge I'm facing is that the if/else statement only addresses the status of btn1. I'm unsure how to query the status of btn2 and subsequent buttons. Something like
btnStatus2=btn2.status...
Any ideas on how to approach this?