JAXP DOM Reference: Difference between revisions
Jump to navigation
Jump to search
Line 66: | Line 66: | ||
| DocumentFragment || "#document-fragment" || null || null | | DocumentFragment || "#document-fragment" || null || null | ||
|- | |- | ||
| DocumentType || same as < | | DocumentType || same as <tt>DocumentType.name</tt> || null || null | ||
|- | |- | ||
| Entity || entity name || null || null | | Entity || entity name || null || null |
Revision as of 03:19, 11 November 2016
External
- Document Object Model (DOM) Level 3 Core Specification https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/
Internal
Overview
For an example of how to walk a DOM tree, see:
Document
Node
Node Types
A node type can be obtained with getNodeType() call, and it is one of the following:
ELEMENT_NODE
ATTRIBUTE_NODE
TEXT_NODE
CDATA_SECTION_NODE
COMMENT_NODE
DOCUMENT_FRAGMENT_NODE
DOCUMENT_NODE
DOCUMENT_TYPE_NODE
ENTITY_NODE
ENTITY_REFERENCE_NODE
NOTATION_NODE
PROCESSING_INSTRUCTION_NODE
Node Name, Value and Attributes
Interface | nodeName | nodeValue | attributes |
Element | Element.tagName | null | NamedNodeMap |
Text | "#text" | same as CharacterData.data, the content of the text node | null |
Attr | same as Attr.name | same as Attr.value | null |
CDATASection | "#cdata-section" | same as CharacterData.data, the content of the CDATA Section | null |
Comment | "#comment" | same as CharacterData.data, the content of the comment | null |
Document | "#document" | null | null |
DocumentFragment | "#document-fragment" | null | null |
DocumentType | same as DocumentType.name | null | null |
Entity | entity name | null | null |
Notation | notation name | null | null |
ProcessingInstruction | same as ProcessingInstruction.target | same as ProcessingInstruction.data | null |
Node's Text Content
To get the text a node contains, you need to look through the list of child nodes, ignoring entries that are of no concern and accumulating the text you find in TEXT nodes, CDATA nodes, and EntityRef nodes.