XML DOM Basics
XML DOM Operations
XML DOM Objects
XML DOM Useful Resources
Selected Reading
- XML DOM - Accessing
- XML DOM - Navigation
- XML DOM - Traversing
- XML DOM - Loading
- XML DOM - Methods
- XML DOM - Node Tree
- XML DOM - Nodes
- XML DOM - Model
- XML DOM - Overview
- XML DOM - Home
XML DOM Operations
- XML DOM - Clone Node
- XML DOM - Remove Node
- XML DOM - Replace Node
- XML DOM - Add Node
- XML DOM - Create Node
- XML DOM - Set Node
- XML DOM - Get Node
XML DOM Objects
- DOM - DOMException Object
- DOM - XMLHttpRequest Object
- DOM - Comment Object
- DOM - CDATASection Object
- DOM - Attribute Object
- DOM - Element Object
- DOM - Notation Object
- DOM - EntityReference Object
- DOM - Entity Object
- DOM - ProcessingInstruction
- DOM - DocumentType Object
- DOM - DOMImplementation
- DOM - NamedNodeMap Object
- DOM - NodeList Object
- DOM - Node Object
XML DOM Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
XML DOM - Clone Node
XML DOM - Clone Node
在本章中,我们将在XML DOM物体上放弃Clone Node的运行。 衣帽子操作被用来制作特定噪音的复制件。
cloneNode()
这种方法回收了这一节点的重复,即作为节点的通用复印件。 重复点子没有母子(母子网无效),也没有用户数据。
Syntax
The cloneNode( methods has the following syntax -
Node cloneNode(boolean deep)
这种方法回收了重复点。
Example
The following example (clonenode_example.htm) parses an XML document (
) into an XML DOM Object and makes a deep拷贝 of the first Employee i> i.<!DOCTYPE html> <html> <head> <script> function loadXMLDoc(filename) { if (window.XMLHttpRequest) { xhttp = new XMLHttpRequest(); } else // code for IE5 and IE6 { xhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.open("GET",filename,false); xhttp.send(); return xhttp.responseXML; } </script> </head> <body> <script> xmlDoc = loadXMLDoc("/dom/node.xml"); x = xmlDoc.getElementsByTagName( Employee )[0]; clone_node = x.cloneNode(true); xmlDoc.documentElement.appendChild(clone_node); firstname = xmlDoc.getElementsByTagName("FirstName"); lastname = xmlDoc.getElementsByTagName("LastName"); contact = xmlDoc.getElementsByTagName("ContactNo"); email = xmlDoc.getElementsByTagName("Email"); for (i = 0;i < firstname.length;i++) { document.write(firstname[i].childNodes[0].nodeValue+ +lastname[i].childNodes[0].nodeValue+ , +contact[i].childNodes[0].nodeValue+ , +email[i].childNodes[0].nodeValue); document.write("<br>"); } </script> </body> </html>
如你在上述例子中可以看到,我们制定了cloneNode( param to true。 因此,在Employe的元素下,每个儿童部分均被复制或掩饰。
Execution
将这一档案作为服务器线路上的clonenode_example.htm(该文档和de.xml在服务器上应当走同样的道路)。 我们将获得以下产出:
Tanmay Patil, 1234567890, tanmaypatil@xyz.com Taniya Mishra, 1234667898, taniyamishra@xyz.com Tanisha Sharma, 1234562350, tanishasharma@xyz.com Tanmay Patil, 1234567890, tanmaypatil@xyz.com
您将注意到第一个Employee元素被完全掩饰。
Advertisements