Extracting text from an XML file based on an element's value?

I have a simple XML file that looks like this:\[code\]<?xml version="1.0" ?><devices><device><name>Inside</name><value>67.662498</value></device><device><name>Outside</name><value>69.124992</value></device></devices>\[/code\]I want to extract the temperature (value) for "Outside" using JavaScript. Here is what I have so far:\[code\]<script type="text/javascript">if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }xmlhttp.open("GET","data.xml",false);xmlhttp.send();xmlDoc=xmlhttp.responseXML;document.getElementById("name").innerHTML=xmlDoc.getElementsByTagName("name")[0].childNodes[0].nodeValue;document.getElementById("value").innerHTML=xmlDoc.getElementsByTagName("value")[0].childNodes[0].nodeValue;</script>\[/code\]When I run this inside an HTML file, it pulls the name "Inside" and its temperature value and not the Outside temperature value. I just want to be able to run this and have "69.124992" show up as the value. What do I need to add to parse this file so it looks only for the device with the name "Outside"?
 
Back
Top