tidyNode::getParent

(PHP 5 >= 5.2.2, PHP 7, PHP 8)

tidyNode::getParentDevuelve el nodo padre del nodo actual

Descripción

publictidyNode::getParent(): ?tidyNode

Devuelve el nodo padre del nodo actualReturns the parent node of the current node.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

Devuelve un tidyNode si el nodo tiene padre, o null de lo contrario.

Ejemplos

Ejemplo #1 Ejemplo de tidyNode::hasChildren()

<?php

$html
= <<< HTML
<html><head>
<?php echo '<title>titulo</title>'; ?>
<#

alert('Hola Mundo');
#>
</head>
<body>
Hola Mundo
</body>
</html>

HTML;


$tidy = tidy_parse_string($html);
$num = 0;

$node = $tidy->html()->child[0]->child[0];

var_dump($node->getparent()->name);
?>

El resultado del ejemplo sería:

string(4) "head"
To Top