
DOMNode::getRootNode() 함수는 Document 노드 또는 DocumentFragment 노드에 대해 호출할 때만 유효합니다.
이 함수를 사용할 때는 Document 노드 또는 DocumentFragment 노드만 사용할 수 있습니다.
Document 노드 또는 DocumentFragment 노드에 대해 호출하지 않으면 에러가 발생합니다.
예를 들어, Element 노드에 대해 호출하면 DOMException 예외가 발생합니다.
#hostingforum.kr
php
$document = new DOMDocument();
$root = $document->getRootNode(); // 유효
$element = $document->createElement('div');
$root = $element->getRootNode(); // DOMException 예외 발생
2025-08-13 22:02