XML DOM » Node » nodeValue

Syntax:
node.nodeValue

This property contains the value of the node, depending on type.

The nodeValue property contains the value of the node, depending on type. The values returned by each node type are detailed below.

  • Element:    null
  • Attr
    the value of the attribute
  • Text
    the content of the text node
  • CDATASection
    the content of the CDATA section
  • EntityReference:    null
  • Entity:    null
  • ProcessingInstruction
    the entire content excluding the target
  • Comment
    the content of the comment
  • Document:    null
  • DocumentType:    null
  • DocumentFragment:    null
  • Notation:    null

Examples

Code:
XML:

<names>
   <name>Alice</name>
   <name>Bert</name>
   <name>Charlie</name>
   <name>Diane</name>
   <name>Eric</name>
</names>

VBScript:

Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("names.xml")

Set objNode = objXMLDoc.documentElement.lastChild
document.write(objNode.nodeValue)
Set objNode = objNode.firstChild
document.write("<br>" & objNode.nodeValue)
Output:
Eric
Null
Explanation:

This example uses the 'names.xml' file and obtains the node values of the last child node of the document's root node (the last 'name' tag), and that node's first child node (the text itself).

Language(s): VBScript XML