Compare two xml values using ajax

wseonottingham3

New Member
OK, so I'm trying to monitor and control something with a Pic-web from microchip. I managed to program it all except for one thing. I need to compare two temperatures that it gives me, and if one of them is smaller that the other then a relay needs to be activated, if its bigger or equal then another relay must be activated. From what I understood Pic-web updates an xml file (status.xml) then the website (using ajax) takes the values from there and displays them on the web page.The XML file looks like this\[code\]<response><temp0>~temp~</temp0><temp2>~tempc~</temp2></response\[/code\]The ajax code I use to get the values in my web page\[code\]document.getElementById('temp0').innerHTML = getXMLValue(xmlData, 'temp0');document.getElementById('temp2').innerHTML = getXMLValue(xmlData, 'temp2');\[/code\]And to display them I use\[code\]<span id="temp0"style="font-weight:normal">?</span><span id="temp2"style="font-weight:normal">?</span>\[/code\]All I need to do is to compare temp0 with temp2\[code\] var temp0 = parseFloat(document.getElementById('temp0').innerHTML) var temp2 = parseFloat(document.getElementById('temp2').innerHTML) if( temp0 < temp2 ) { document.getElementById('temp3').innerHTML = '<font color="#00FF00">ON</font>'; } else { document.getElementById('temp3').innerHTML = '<font color="#00FFFF">OFF</font>';}\[/code\]The I just add \[code\]<span id="temp3">?</span>\[/code\] to display the resultAm I correct?
 
Back
Top