title: Compare two xml values using ajax
body: <p>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.</p>
  
  <p>The XML file looks like this</p>
  
  <pre><code>&lt;response&gt;
  &lt;temp0&gt;~temp~&lt;/temp0&gt;
  &lt;temp2&gt;~tempc~&lt;/temp2&gt;
  &lt;/response
  </code></pre>
  
  <p>The ajax code I use to get the values in my web page</p>
  
  <pre><code>document.getElementById('temp0').innerHTML = getXMLValue(xmlData, 'temp0');
  document.getElementById('temp2').innerHTML = getXMLValue(xmlData, 'temp2');
  </code></pre>
  
  <p>And to display them I use</p>
  
  <pre><code>&lt;span id="temp0"style="font-weight:normal"&gt;?&lt;/span&gt;
  &lt;span id="temp2"style="font-weight:normal"&gt;?&lt;/span&gt;
  </code></pre>
  
  <p>All I need to do is to compare temp0 with temp2</p>
  
  <pre><code>    var temp0 = parseFloat(document.getElementById('temp0').innerHTML)
      var temp2 = parseFloat(document.getElementById('temp2').innerHTML)
  
      if( temp0 &lt; temp2 ) 
      {
          document.getElementById('temp3').innerHTML = '&lt;font color="#00FF00"&gt;ON&lt;/font&gt;';
      } 
      else 
      {
          document.getElementById('temp3').innerHTML = '&lt;font color="#00FFFF"&gt;OFF&lt;/font&gt;';
  
  }
  </code></pre>
  
  <p>The I just add <code>&lt;span id="temp3"&gt;?&lt;/span&gt;</code> to display the result</p>
  
  <p>Am I correct?</p>