HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
The nodeName, nodeValue, and nodeType properties contain information about nodes
In the XML DOM, each node is an object.
Objects have methods and properties, that can be accessed and manipulated by JavaScript.
Three important node properties are:
The nodeName property specifies the name of a node.
The nodeValue property specifies the value of a node.
The following code retrieves the text node value of the first <title> element:
var x = xmlDoc.getElementsByTagName("title")[0].childNodes[0];
var txt = x.nodeValue;
Result: txt = "Everyday Italian"
Example explained:
The following code changes the text node value of the first <title> element:
var x = xmlDoc.getElementsByTagName("title")[0].childNodes[0];
x.nodeValue = "Easy Cooking";
Example explained:
The nodeType property specifies the type of node.
nodeType is read only.
The most important node types are:
Node type | NodeType |
---|---|
Element | 1 |
Attribute | 2 |
Text | 3 |
Comment | 8 |
Document | 9 |