XML DOM 노드 타입

DOM은 문서를 노드 객체의 계층 구조로 표현합니다.

노드 타입

다음 표는 다양한 W3C 노드 타입과 그들이 가질 수 있는 자식 요소를 나열합니다:

노드 타입 설명 자식 요소
Document 전체 문서(DOM 트리의 루트 노드)를 나타냅니다.
  • Element (최대 하나)
  • ProcessingInstruction
  • Comment
  • DocumentType
DocumentFragment 문서의 일부를 포함한 가벼운 Document 객체를 나타냅니다.
  • ProcessingInstruction
  • Comment
  • Text
  • CDATASection
  • EntityReference
DocumentType 문서에 정의된 엔티티에 대한 인터페이스를 제공합니다. None
ProcessingInstruction processing instruction을 나타냅니다. None
EntityReference 엔티티 참조 요소를 나타냅니다.
  • ProcessingInstruction
  • Comment
  • Text
  • CDATASection
  • EntityReference
Element element(요소) 요소를 나타냅니다.
  • Text
  • Comment
  • ProcessingInstruction
  • CDATASection
  • EntityReference
Attr 속성을 나타냅니다.
  • Text
  • EntityReference
Text 요소나 속성에서의 텍스트 내용을 나타냅니다. None
CDATASection 문서에서 CDATA 구간(텍스트가 파서에 의해 분석되지 않습니다)을 나타냅니다. None
Comment 주석을 나타냅니다. None
엔티티 엔티티를 나타냅니다.
  • ProcessingInstruction
  • Comment
  • Text
  • CDATASection
  • EntityReference
notation DTD에서 선언된 기호를 나타냅니다. None

노드 타입 - 반환된 값

다음 표는 각 노드 타입에 대해 nodeName과 nodeValue 속성이 반환할 수 있는 값을 나열합니다:

노드 타입 nodeName의 반환 값 nodeValue의 반환 값
Document #document null
DocumentFragment #document fragment null
DocumentType doctype 이름 null
EntityReference 엔티티 참조 이름 null
Element 요소 이름 null
Attr 속성 이름 속성 값
ProcessingInstruction target 노드 내용
Comment #comment 주석 텍스트
Text #text 노드 내용
CDATASection #cdata-section 노드 내용
엔티티 엔티티 이름 null
notation 기호 이름 null

노드 타입 - 이름 지정된 상수

노드 타입 이름 지정된 상수
1 ELEMENT_NODE
2 ATTRIBUTE_NODE
3 TEXT_NODE
4 CDATA_SECTION_NODE
5 ENTITY_REFERENCE_NODE
6 ENTITY_NODE
7 PROCESSING_INSTRUCTION_NODE
8 COMMENT_NODE
9 DOCUMENT_NODE
10 DOCUMENT_TYPE_NODE
11 DOCUMENT_FRAGMENT_NODE
12 NOTATION_NODE