MSXML Æļ ¼³Ä¡ÇÒ °æ¿ì | MSXML Æļ ¼³Ä¡¾ÈÇÑ °æ¿ì |
<HTML> <HEAD> <Script language="Javascript"> function xload0() { var xmldoc = new ActiveXObject("Msxml2.DOMDocument"); xmldoc.async = false; xmldoc.load("ex07a.xml"); alert(xmldoc.xml); } </script> </HEAD> <BODY> <input type="button" value="XML ·Îµå0" onClick="xload0()"> </BODY> </HTML> |
<HEAD> <Script language="Javascript"> function xload1() { xmldoc.async = false; xmldoc.load("ex07a.xml"); alert(xmldoc.xml); } </script> </HEAD> <BODY> <input type="button" value="XML ·Îµå1" onClick="xload1()"> <xml id="xmldoc"></xml> </BODY> </HTML> |
VBScript ÀÇ °æ¿ì | |
<Script
language="VbScript"> Dim xmldoc Set xmldoc = CreateObject("Msxml2.DOMDocument") xmldoc.async = False; xmldoc.load("ex07a.xml"); MsgBox xmldoc.xml </Script> |
xmldoc.async = false; xmldoc.loadXML( "<book><title>XML ÀÔ¹®</title><author>ÀÏÁö¸Å</author></book>"); alert(xmldoc.xml); |
xmldoc.async = false; xmldoc.loadXML( "<book> <title> XML ÀÔ¹® </title> <author> ÀÏÁö¸Å </author> </book>"); alert(xmldoc.xml); |
xmldoc.async = false; xmldoc.preserveWhiteSpace = true; xmldoc.loadXML( "<book> <title> XML ÀÔ¹® </title> <author> ÀÏÁö¸Å </author> </book>"); alert(xmldoc.xml); |
xmldoc.async = false; xmldoc.preserveWhiteSpace = true; xmldoc.load("ex07a.xml"); alert(xmldoc.xml); |
xmldoc.async = false; xmldoc.loadXML( "<book> <title> XML ÀÔ¹® </title> <author> ÀÏÁö¸Å </authors> </book>"); alert(xmldoc.xml); |
xmldoc.async = false; xmldoc.loadXML( "<book> <title> XML ÀÔ¹® </title> <author> ÀÏÁö¸Å </authors> </book>"); if (xmldoc.parseError) alert("¿¡·¯ À§Ä¡ : " + xmldoc.parseError.line + "¹ø° ¶óÀÎ " + xmldoc.parseError.linepos + "¹ø° ¹®ÀÚ\n\n¿¡·¯ ÀÌÀ¯ : " + xmldoc.parseError.reason); else alert(xmldoc.xml); |
xmldoc.async = false; xmldoc.load("ex07a.xml"); var xmlroot = xmldoc.documentElement; alert(xmlroot.nodeName); |
xmldoc.async = false; xmldoc.loadXML( "<book> <title> XML ÀÔ¹® </title> <author> ÀÏÁö¸Å </author> </book>"); var xmlroot = xmldoc.documentElement; alert(xmlroot.nodeName); |
xmldoc.load("ex07a.xml"); var xmlroot = xmldoc.documentElement; alert('nodeName: '+xmlroot.nodeName+'\nnodeType: '+xmlroot.nodeType+ '\nnodeValue: '+xmlroot.nodeValue+'\nattributes: '+xmlroot.attributes.length); alert(xmlroot.text); |
xmldoc.load("ex07a.xml"); var xmlroot = xmldoc.documentElement; if (xmlroot.hasChildNodes) { alert(xmlroot.childNodes.length); var curr = xmlroot.firstChild; alert(curr.xml); alert(curr.nodeName + curr.nodeType +curr.nodeValue+curr.attributes.length); } else alert('No Child'); |
xmldoc.load("ex07a.xml"); var xmlroot = xmldoc.documentElement; var curr = xmlroot.firstChild.nextSibling; alert(curr.xml); curr = curr.childNodes.item(2); alert(curr.xml); curr = curr.previousSibling; alert(curr.text); alert(curr.nodeName + curr.nodeType +curr.nodeValue+curr.attributes.length); |
xmldoc.load("ex07a.xml");
var attrs = xmlroot.firstChild.attributes; var attr0 = attrs.getNamedItem("InStock"); alert(attr0.name + attr0.value + attr0.specified); |
xmldoc.load("ex07a.xml"); var nlist = xmldoc.getElementsByTagName("book"); for (i=0; i<nlist.length; i++) alert(nlist.item(i).xml); |
xmldoc.load("ex07a.xml"); var nlist = xmldoc.getElementsByTagName("title"); for (i=0; i<nlist.length; i++) alert(nlist.item(i).xml); |
xmldoc.load("ex07a.xml"); var xroot = xmldoc.documentElement; var node1 = xroot.selectSingleNode("title"); alert(node1.text); var tlist = xroot.selectNodes('//title'); var alist = xroot.selectNodes('//author'); for (i=0; i<alist.length; i++) alert('['+i+'] '+alist.item(i).text+', ' +tlist.item(i).text); |
xmldoc.load("ex07a.xml"); var xroot = xmldoc.documentElement; var node1 = xroot. selectSingleNode('//book[@InStock=0]'); alert(node1.xml+'\n=> Àç°í°¡ ¾ø½À´Ï´Ù.'); var tlist = xroot. selectNodes('//book[@InStock!=0]/title'); for (i=0; i<tlist.length; i++) alert(tlist.item(i).text+'\n=>Àç°í ÀÖÀ½.'); |