-
Notifications
You must be signed in to change notification settings - Fork 20
Query Parent
Thomas Weinert edited this page Jul 30, 2014
·
1 revision
FluentDOM\Query parent()
Get a set of elements containing the unique parents of the matched set of elements.
$html = <<<HTML
<html>
<head>
<title>Examples: FluentDOM\Query::parent()</title>
</head>
<body>
<div>div,
<span>span, </span>
<b>b </b>
</div>
<p>p,
<span>span,
<em>em </em>
</span>
</p>
<div>div,
<strong>strong,
<span>span, </span>
<em>em,
<b>b, </b>
</em>
</strong>
<b>b </b>
</div>
</body>
</html>
HTML;
echo FluentDOM($html)
->find('//body//*')
->each('callback');
function callback($node) {
$fluentNode = FluentDOM($node);
$fluentNode->prepend(
$fluentNode->document->createTextNode(
$fluentNode->parent()->item(0)->tagName.' > '
)
);
}
<?xml version="1.0"?>
<html>
<head>
<title>Examples: FluentDOM\Query::parent()</title>
</head>
<body>
<div>body > div,
<span>div > span, </span>
<b>div > b </b>
</div>
<p>body > p,
<span>p > span,
<em>span > em </em>
</span>
</p>
<div>body > div,
<strong>div > strong,
<span>strong > span, </span>
<em>strong > em,
<b>em > b, </b>
</em>
</strong>
<b>div > b </b>
</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