function getXMLDocument() {
var xDoc = null;
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><?XML:NAMESPACE PREFIX = O />
// 파이어폭스
if (document.implementation && document.implementation.createDocument) {
xDoc = document.implementation.createDocument("","",null);
// 익스플로러
} else if (typeof ActiveXObject != "undefined") {
var msXmlAx = null;
try {
//최신버젼
msXmlAx = new ActiveXObject("Msxml2.DOMDocument");
}
catch (e) {
//구 버젼
msXmlAx = new ActiveXObject("Msxml.DOMDocument");
}
xDoc = msXmlAx;
}
return xDoc;
}
function xDocHandler () {
var xDocPath = 'test.xml';
this.objXdoc;
this.xDoc = getXMLDocument
this.objXdoc = this.xDoc();
this.objXdoc.async = false;
this.objXdoc.load(xDocPath);
}
function xDocNodeSearch(str) {
var xDoc = new xDocHandler();
var XmlDoc = xDoc.objXdoc.getElementsByTagName('item');
var cnt = XmlDoc.length;
for (var i = 0; i < cnt; i++) {
if (XmlDoc[i].getAttribute('name') == str) {
var alts = '[메세지] ' + xDoc.objXdoc.getElementsByTagName('msg')[i].firstChild.data;
alts += '\n\n[링크]' + xDoc.objXdoc.getElementsByTagName('link')[i].firstChild.data;
alert(alts);
}
}
}
xDocNodeSearch('test');
# test.xml <xml 문서>
<?xml version="1.0" encoding="euc-kr" ?>
<message>
<item name="test">
<msg>안녕하세요. Syaku 블로그 입니다.</msg>
<link>http://blog.naver.com/syaku</link>
</item>
<item name="test2">
<msg>안녕하세요. 샤쿠 블로그 입니다.</msg>
<link>http://blog.naver.com/syaku</link>
</item>
</message>
작성자 샤쿠
"쇼핑몰·홈페이지·오픈마켓
블로그·페이스북·이메일 등의 각종 마케팅 글쓰기, 각종 광고, 영업, 판매, 제안서, 전단지 반응율 3배×10배 이상 높이는 마법의 8단계 공식" |
☞자세히보기 |
|
|