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 - Set Node
XML DOM - Set Node
在本章中,我们将研究如何改变锡马解放组织DOM物体中的节点价值。 名义价值可改变如下:
var value = node.nodeValue;
如果node 是Attribute,则 Value/i>变量将是特性值;node 是Text。 定本为案文内容;如果node为 Element,则为null。
下面各节将显示每个节点(标题、案文节点和元件)的定值。
node.xml 以下所有例子都使用:
<Company> <Employee category = "Technical"> <FirstName>Tanmay</FirstName> <LastName>Patil</LastName> <ContactNo>1234567890</ContactNo> <Email>tanmaypatil@xyz.com</Email> </Employee> <Employee category = "Non-Technical"> <FirstName>Taniya</FirstName> <LastName>Mishra</LastName> <ContactNo>1234667898</ContactNo> <Email>taniyamishra@xyz.com</Email> </Employee> <Employee category = "Management"> <FirstName>Tanisha</FirstName> <LastName>Sharma</LastName> <ContactNo>1234562350</ContactNo> <Email>tanishasharma@xyz.com</Email> </Employee> </Company>
Change Value of Text Node
当我们说诺德要素的改变价值时,我们就意味着要篡改要素的内容(也称作text node)。 下面举例说明如何改变一个要素的案文节点。
Example
以下例子(第_text_node_example.htm)将XML文件(
)细分为XMLDOM物体,并更改元素案文的数值。 在这种情况下, Email of each Employe to support@xyz.com,并印刷这些数值。<!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("Email"); for(i = 0;i<x.length;i++) { x[i].childNodes[0].nodeValue = "support@xyz.com"; document.write(i+ ); document.write(x[i].childNodes[0].nodeValue); document.write( <br> ); } </script> </body> </html>
Execution
Save this file as set_text_node_example.htm on the services path (this file and