<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html LANG="ja-JP">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<META http-equiv="Content-Script-Type" content="text/javascript">
<title>テストページ</title>
<script type="text/javascript"><!--
function viewText(name)
{
httpobj = createHttpRequest();
httpobj.open( "GET", name, false );
httpobj.send(null);
try
{
document.getElementById('text').value = httpobj.responseXML.documentElement.innerText;
}
catch(e)
{
document.getElementById('text').value = "例外発生: " + httpobj.responseText;
}
}
function createHttpRequest()
{
//Win IE用
if(window.ActiveXObject){
try {
//MSXML2以降用
return new ActiveXObject("Msxml2.XMLHTTP")
} catch (e) {
try {
//旧MSXML用
return new ActiveXObject("Microsoft.XMLHTTP")
} catch (e2) {
return null
}
}
} else if(window.XMLHttpRequest){
//Win IE以外のXMLHttpRequestオブジェクト実装ブラウザ用
return new XMLHttpRequest()
} else {
return null
}
}
// --></script>
</head>
<body>
<p>
<input type="button" onclick="viewText('data1utf8.xml');"
value="UTF-8で読み込む" ></input>
<input type="button" onclick="viewText('data1utf16.xml');"
value="UTF-16で読み込む" ></input>
</p>
<textarea id="text" rows="6" cols="40" readOnly></textarea>
</body>
</html>