xmlを取得する
<test> <sample>米ドル/円</sample> <sample>ユーロ円</sample> <sample>豪ドル/円</sample> </test>
<form> <input type="button" name="submit" value="表示" id=button> </form> <div id="result"></div> <script> function createXMLHttpRequest() { if (window.XMLHttpRequest) { return new XMLHttpRequest() } else if (window.ActiveXObject) { try { return new ActiveXObject("Msxml2.XMLHTTP") } catch (e) { try { new ActiveXObject("Microsoft.XMLHTTP") } catch (e2) { return null } } } else { return null } } function send(){ var url = "sample.xml"; var request = createXMLHttpRequest(); request.open("GET", url, true); request.onreadystatechange = function(){ if(request.readyState == 4 && request.status == 200){ var result = document.getElementById("result"); var xml = request.responseXML; var nodes = xml.getElementsByTagName("sample"); var text = nodes[0].firstChild.nodeValue; result.innerHTML =text; } } request.send(""); } window.onload = function(){ document.getElementById("button").onclick = send; } </script>