¹®¼¿¡ ³ëµå Ãß°¡ ¹æ¹ý |
||
¡¡ |
1. ¹®¼ ³»¿¡ ½Å±Ô ³ëµå ¸¸µé±â
2. ¿øÇÏ´Â ³ëµå ¹Ø¿¡ ºÙÀ̱â
|
|
xdoc.async = false; xdoc.loadXML( "<book> <title> XML ÀÔ¹® </title> <author> ÀÏÁö¸Å </author> </book>"); elmt = xdoc.createElement("pages"); alert(elmt.xml); pg = xdoc.createTextNode("386"); alert(pg.xml); stock = xdoc.createAttribute("Instock"); alert(stock.xml); cmt = xdoc.createComment("³ëµåÃß°¡"); alert(cmt.xml); pi = xdoc.createProcessingInstruction("xml-stylesheet", "type='text/xsl' href='ex8.xsl'"); alert(pi.xml); cd = xdoc.createCDATASection("<1>"); alert(cd.xml); alert(xdoc.xml); |
xdoc.loadXML(
"<book> <title> XML
ÀÔ¹® </title> <author> ÀÏÁö¸Å </author> </book>"); elmt = xdoc.createElement("pages"); pg = xdoc.createTextNode("386"); elmt.appendChild(pg); alert(elmt.xml +'\n----------\n' + xdoc.xml); xroot = xdoc.documentElement; xroot.appendChild(elmt); alert(xdoc.xml); |
xdoc.loadXML(
"<book> ... </book>"); cmt = xdoc.createComment("³ëµåÃß°¡"); xdoc.appendChild(cmt); alert(xdoc.xml); // ¹®¼¿¡ ³ëµå ¿¬°á xroot = xdoc.documentElement; alert('[root] : '+xroot.nodeName); pi = xdoc.createProcessingInstruction("xml-stylesheet", "type='text/xsl' href='ex7.xsl'"); xdoc.insertBefore(pi,xroot); alert(xmldoc.xml); // ¹®¼¿¡ ³ëµå ¿¬°á xroot = xdoc.documentElement; alert('[root] : '+xroot.nodeName); |
cmt =
xdoc.createComment("³ëµåÃß°¡"); xdoc.insertBefore(cmt, xdoc.firstChild); alert('[xdoc] :\n'+xdoc.xml); xroot = xdoc.documentElement; alert('[root] : '+xroot.nodeName); elmt = xdoc.createElement('list'); elmt.appendChild(xroot); alert('[elmt] :\n\n'+elmt.xml); xdoc.documentElement = elmt; alert('[xdoc] :\n\n'+xdoc.xml); |
xdoc.loadXML( "<book> <title> XML
ÀÔ¹® </title> <author> ÀÏÁö¸Å </author>
</book>"); xroot = xdoc.documentElement; elmt = xroot.firstChild; node=elmt.removeChild(elmt); alert('[»èÁ¦] :\n\n'+node.nodeValue); alert('[°á°ú] :\n\n'+xdoc.xml); elmt = xroot.lastChild; node=xroot.removeChild(elmt); alert('[»èÁ¦] :\n\n'+node.xml); alert('[°á°ú] :\n\n'+xdoc.xml); |
xdoc.loadXML(
"<book> ... </book>"); elmt = xdoc.createElement('price'); cur = xdoc.createAttribute('currency'); alert(cur.xml); elmt.attributes.setNamedItem(cur); alert(elmt.xml); cur.nodeValue = 'won'; elmt.text = '33000'; alert(elmt.xml); stock = xdoc.createAttribute('InStock'); stock.nodeValue=7; alert(stock.xml); xroot = xdoc.documentElement; xroot.appendChild(elmt); xroot.attributes.setNamedItem(stock); alert(xdoc.xml); |
xdoc.loadXML(
"<book> ... </book>"); elmt = xdoc.createElement('price'); elmt.setAttribute('currency','won'); elmt.text = '33000'; alert(elmt.xml); xroot = xdoc.documentElement; xroot.appendChild(elmt); xroot.setAttributes('InStock','7'); alert(xdoc.xml); st1 = xroot.getAttribute('InStock'); st2 = xroot.attributes.getNamedItem('InStock'); alert('[1] '+st1+'\n[2] '+st2.xml); xroot.setAttribute('InStock','9'); alert(xroot.xml); xroot.removeAttribute('InStock'); alert(xdoc.xml); |
xdoc.loadXML('<book> <title> XML ÀÔ¹®
</title> <author> ÀÏÁö¸Å </author> </book>'); xroot = xdoc.documentElement; tnode=xroot.firstChild.firstChild; alert('[length] : '+tnode.length+'-------'+tnode.data); alert(tnode.substringData(5,1) +''+tnode.substringData(2,200)); tnode.appendData('**'); tnode.insertData(5,'**'); alert(tnode.text); tnode.deleteData(5,2); tnode.replaceData(7,3,' #'); alert(tnode.data); |
xdoc.loadXML('<book> ...
</book>'); xroot = xdoc.documentElement; elmt = xroot.firstChild; tnode=elmt.firstChild; tnode.splitText(5); alert(elmt.xml+'------'+tnode.data+'-------'+elmt.lastChild.data); node = xmldoc.createElement('br'); elmt.insertBefore(node,elmt.lastChild); alert(elmt.xml); |
<HTML> |
xdoc.async =
false; xdoc.load('ex07a.xml'); alert(xdoc.xml); xsldoc.async = false; xsldoc.load('ex07a.xsl'); alert(xsldoc.xml); var newdoc = xdoc.transformNode(xsldoc.XMLDocument); alert(newdoc); document.write(newdoc); |
¡¡