XML DOM Node 객체
- Previous Page DOM Node Type
- Next Page DOM NodeList
Node 객체
Node 객체는 문서 트리에서의 단일 노드를 나타냅니다.
노드는 요소 노드, 속성 노드, 텍스트 노드 또는 '노드 타입' 장에서 설명된 어떤 노드일 수 있습니다.
모든 객체는 부모 노드와 자식 노드를 처리하는 속성과 메서드를 상속할 수 있지만, 모든 객체가 부모 노드나 자식 노드를 가지고 있지 않습니다. 예를 들어, 텍스트 노드는 자식 노드를 가질 수 없기 때문에 이와 유사한 노드에 자식 노드를 추가하면 DOM 오류가 발생합니다.
Node 객체의 속성
속성 | 설명 |
---|---|
attributes | 이 노드를 포함하는 속성의 NamedNodeMap(이 노드가 요소라면) |
baseURI | 노드의 절대 기준 URI를 반환합니다. |
childNodes | 노드의 자식 노드 NodeList을 반환합니다. |
firstChild | 노드의 첫 번째 자식 노드를 반환합니다. |
lastChild | 노드의 마지막 자식 노드를 반환합니다. |
nextSibling | 노드 뒤에 가장 가까운 동일 등급 노드를 반환합니다. |
nodeName | 노드의 이름을 반환합니다. 타입에 따라 다릅니다. |
nodeType | 노드의 타입을 반환합니다. |
nodeValue | 노드의 값을 설정하거나 반환합니다. 타입에 따라 다릅니다. |
ownerDocument | 노드의 뿌리 요소(문서 객체)를 반환합니다. |
parentNode | 노드의 부모 노드를 반환합니다. |
prefix | 노드의 이름 공간 접두사를 설정하거나 반환합니다. |
previousSibling | 노드 앞에 가장 가까운 동일 등급 노드를 반환합니다. |
textContent | 노드 및 자식의 텍스트 내용을 설정하거나 반환합니다. |
Node 객체의 메서드
메서드 | 설명 |
---|---|
appendChild() | 새로운 자식 노드를 노드 자식 노드 목록의 마지막에 추가합니다. |
cloneNode() | 노드를 복사합니다. |
compareDocumentPosition() | DOM 계층 구조(문서)에서 두 노드의 위치를 비교합니다. |
getFeature(feature,version) | 지정된 특성과 버전의 전용 API를 구현한 DOM 객체를 반환합니다. |
getUserData(key) |
노드에 있는 키와 연결된 대상을 반환합니다. 먼저 대상을 이 노드에 설정해야 합니다. 같은 키를 사용하여 setUserData를 호출합니다. |
hasAttributes() | Return true if the specified node has any attributes, otherwise return false. |
hasChildNodes() | Return true if the specified node has child nodes, otherwise return false. |
insertBefore() | Insert a new child node before the specified child node. |
isDefaultNamespace(URI) | Return whether the specified namespace URI is the default. |
isEqualNode() | Check if two nodes are equal. |
isSameNode() | Check if two nodes are the same node. |
lookupNamespaceURI() | Return the namespace URI associated with the given prefix. |
lookupPrefix() | Return the prefix associated with the given namespace URI. |
normalize() | Merge adjacent text nodes and delete empty text nodes. |
removeChild() | Delete (and return) the specified child node of the current node. |
replaceChild() | Replace the child node with a new node. |
setUserData(key,data,handler) | Associate an object with a key on the node. |
- Previous Page DOM Node Type
- Next Page DOM NodeList