-
Notifications
You must be signed in to change notification settings - Fork 20
Query Parents
Thomas Weinert edited this page Jul 12, 2018
·
2 revisions
FluentDOM\Query parents([ $selector = NULL ])
Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.
$html = <<<HTML
<html>
<head>
<title>Examples: FluentDOM\Query::parents()</title>
</head>
<body>
<div>
<p>
<span>
<b>My parents are: </b>
</span>
</p>
</div>
</body>
</html>
HTML;
$fdQuery = FluentDOM($html);
$parents = implode(
', ',
$fdQuery
->find('//b')
->parents()
->map(
create_function('$node', 'return $node->tagName;')
)
);
echo $fdQuery
->find('//b')
->append('<strong>'.htmlspecialchars($parents).'</strong>');
<?xml version="1.0"?>
<html>
<head>
<title>Examples: FluentDOM\Query::parents()</title>
</head>
<body>
<div>
<p>
<span>
<b>My parents are: <strong>span, p, div, body, html</strong></b>
</span>
</p>
</div>
</body>
</html>
- Home
- Getting Started
- Tasks
- Plugins
- Functions
- Lists
- Creator (5.1)
- CSS Selectors
- Convertors
- Loaders
- Serializers (5.1)
- Transformers (5.1)
- Extended DOM
- XMLReader (6.1)
- XMLWriter (6.1)
- Interfaces