复制一个节点,并把它追加到已有的节点
- <html>
- <head>
- <script type="text/javascript" src="/example/xdom/loadxmldoc.js">
- </script>
- </head>
- <body>
- <script type="text/javascript">
- xmlDoc=loadXMLDoc("/example/xdom/books.xml");
- x=xmlDoc.getElementsByTagName('book')[0];
- cloneNode=x.cloneNode(true);
- xmlDoc.documentElement.appendChild(cloneNode);
- //Output all titles
- y=xmlDoc.getElementsByTagName("title");
- for (i=0;i<y.length;i++)
- {
- document.write(y[i].childNodes[0].nodeValue);
- document.write("<br />");
- }
- </script>
- </body>
- </html>