php8.5
Home/ Manual/ dom / domnode/ DOMNode::getRootNode

DOMNode::getRootNode

PHP function Edit on GitHub ✎

(PHP 8 >= 8.3.0)

Get root node

Description

DOMNode::getRootNode(array|null $options = null): DOMNode

Get root node.

Parameters

options

This parameter has no effect yet.

Return Values

Returns the root node.

Examples

DOMNode::getRootNode example

php
<?php

$dom = new DOMDocument();
$dom->loadXML('<?xml version="1.0"?><html><body/></html>');

var_dump($dom->documentElement->firstElementChild->getRootNode() === $dom);
?>

The above example will output:

output
bool(true)

Source: reference/dom/domnode/getrootnode.xml · from the official PHP manual (php/doc-en)