*poem.xml
<?xml version="1.0" encoding="euc-kr"?>
<sijip>
<poem poet="윤동주">
하늘을 우러러 한점 부끄럼 없기를 잎새에 이는 바람에도 나는 괴로워했다.
</poem>
<poem poet="김소월">
나보기가 역겨워 가실때에는 말없이 고이 보내 드리오리다.
</poem>
</sijip>
* dom.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<SCRIPT LANGUAGE="JavaScript">
<!--
function display() {
xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async = false;
xmldoc.load("poem.xml");
var string = "";
var poet = "";
if (xmldoc.documentElement.hasChildNodes())
{
for (i=0;i<xmldoc.documentElement.childNodes.length ;i++ )
{
poet = "시인이름: " + xmldoc.documentElement.childNodes.item(i).attributes.item(0).text + "<br/>";
string += "<p>";
string += poet + xmldoc.documentElement.childNodes.item(i).text;
string += "</p>"
}
}
poem.innerHTML = string;
}
//-->
</SCRIPT>
</HEAD>
<BODY onload="display()">
<div id="poem" align="center"></div>
</BODY>
</HTML>
'자바 스크립트' 카테고리의 다른 글
| 종합예제-시집 만들기 (0) | 2009.06.22 |
|---|---|
| firstChild를 이용한 방법 (0) | 2009.06.22 |
| 자식노드 조사하기 (0) | 2009.06.19 |
| DOM(Document Object Model) (0) | 2009.06.19 |
| 정규표현식-날짜체크 (0) | 2009.06.18 |