Name

nodeName: DOMString

Synopsis

Intended to represent the underlying DOM object’s name. Depending on the object type, this attribute may map to another attribute of the object or a constant string, as listed in this table:

Object type

nodeName

Element

Tag name

Attr

Attribute name

Text

“#text”

CDATASection

“#cdata-section”

EntityReference

Name of entity referenced

Entity

Entity name

ProcessingInstruction

Target

Comment

“#comment”

Document

“#document”

DocumentType

Document type name

DocumentFragment

“#document-fragment”

Notation

Notation name

Java binding

public String getNodeName( );
     
// Print the document root tag name
Node ndDoc = (Node)doc.getDocumentElement( );
System.out.println("Document root element type: " + ndDoc.getNodeName( ));

Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.