<?xml version="1.0"?> <order num="312597"> <date>2000/1/1</date> <customer id="216A">Company A</customer> <item> <part-no ware="W11">E16-25</part-no> <descr>Widget</descr> <quantity>16</quantity> </item> </order> |
|
MSXML Æļ ¼³Ä¡ÇÑ °æ¿ì | MSXML Æļ ¼³Ä¡¾ÈÇÑ °æ¿ì |
<HTML> <HEAD> <Script language="Javascript"> function xload0() { var xdoc = new ActiveXObject("Msxml.DOMDocument"); xdoc.async = false; xdoc.load("ex08.xml"); alert(xdoc.xml); } </script> </HEAD> <BODY> <input type="button" value="XML ·Îµå0" onClick="xload0()"> </BODY> </HTML> |
<HEAD> <Script language="Javascript"> function xload1() { xdoc.async = false; xdoc.load("ex08.xml"); alert(xdoc.xml); } </script> </HEAD> <BODY> <input type="button" value="XML ·Îµå1" onClick="xload1()"> <xml id="xdoc"></xml> </BODY> </HTML> |
VBScript ÀÇ °æ¿ì | |
<Script
language="VbScript"> Dim xdoc Set xdoc = CreateObject("Msxml.DOMDocument") xdoc.async = False; xdoc.load("ex08.xml"); MsgBox xdoc.xml </Script> |
xdoc.async = false; xdoc.loadXML( "<book><title>XML ÀÔ¹®</title><author>ÀÏÁö¸Å</author></book>"); alert(xdoc.xml); |
xdoc.async = false; xdoc.loadXML( "<book> <title> XML ÀÔ¹® </title> <author> ÀÏÁö¸Å </author> </book>"); alert(xdoc.xml); |
xdoc.async = false; xdoc.preserveWhiteSpace = true; xdoc.loadXML( "<book> <title> XML ÀÔ¹® </title> <author> ÀÏÁö¸Å </author> </book>"); alert(xdoc.xml); |
xdoc.async = false; xdoc.preserveWhiteSpace = true; xdoc.load("ex07a.xml"); alert(xdoc.xml); |
xdoc.async = false; xdoc.loadXML( "<book> <title> XML ÀÔ¹® </title> <author> ÀÏÁö¸Å </authors> </book>"); alert(xdoc.xml); |
xdoc.async = false; xdoc.loadXML( "<book> <title> XML ÀÔ¹® </title> <author> ÀÏÁö¸Å </authors> </book>"); if (xdoc.parseError) alert("¿¡·¯ À§Ä¡ : " + xdoc.parseError.line + "¹ø° ¶óÀÎ " + xdoc.parseError.linepos + "¹ø° ¹®ÀÚ\n\n¿¡·¯ ÀÌÀ¯ : " + xdoc.parseError.reason); else alert(xdoc.xml); |
xdoc.async = false; xdoc.load("ex08.xml"); var xroot = xdoc.documentElement; alert(xroot.nodeName); |
xdoc.async = false; xdoc.loadXML( "<book> <title> XML ÀÔ¹® </title> <author> ÀÏÁö¸Å </author> </book>"); var xroot = xdoc.documentElement; alert(xroot.nodeName); |
xdoc.load("ex08.xml"); var xroot = xdoc.documentElement; alert('nodeName: '+xroot.nodeName+'\nnodeType: '+xroot.nodeType+ '\nnodeValue: '+xroot.nodeValue+'\nattributes: '+xroot.attributes.length); alert(xroot.text); |
xdoc.load("ex08.xml"); var xroot = xdoc.documentElement; if (xroot.hasChildNodes) { alert(xroot.childNodes.length); var curr = xroot.firstChild; alert(curr.xml); alert(curr.nodeName + curr.nodeType +curr.nodeValue+curr.attributes.length); } else alert('No Child'); |
xdoc.load("ex08.xml"); var xroot = xdoc.documentElement; var curr = xroot.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); |
xdoc.load("ex08.xml"); var xroot = xdoc.documentElement; var attrs = xroot.firstChild.attributes; var attr0 = attrs.getNamedItem("InStock"); alert(attr0.nodeName + attr0.nodeValue ); |
xdoc.load("ex08.xml"); var nlist = xdoc.getElementsByTagName("book"); for (i=0; i<nlist.length; i++) alert(nlist.item(i).xml); |
xdoc.load("ex08.xml"); var nlist = xdoc.getElementsByTagName("title"); for (i=0; i<nlist.length; i++) alert(nlist.item(i).xml); |
xdoc.load("ex08.xml"); var xroot = xdoc.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); |
xdoc.load("ex08.xml"); var xroot = xdoc.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=>Àç°í ÀÖÀ½.'); |