Skip to content
Thomas Weinert edited this page Jul 30, 2014 · 1 revision

FluentDOM\Query::children()

FluentDOM\Query children([ string $selector = NULL ]);

Get a set of elements containing of the unique immediate child nodes including only elements (not text nodes) of each of the matched set of elements.

Usage

$xml = <<<XML
<html>
  <head>
    <title>Examples: FluentDOM\Query::children()</title>
  </head>
  <body>
    <div id="container">
      <p>This <span>is the <em>way</em> we</span>
      write <em>the</em> demo,</p>
    </div>
  </body>
</html>
XML;

echo FluentDOM($xml)
  ->find('//div[@id = "container"]/p')
  ->children()
  ->toggleClass('child');

Output

<?xml version="1.0"?>
<html>
  <head>
    <title>Examples: FluentDOM\Query::children()</title>
  </head>
  <body>
    <div id="container">
      <p>This <span class="child">is the <em>way</em> we</span>
      write <em class="child">the</em> demo,</p>
    </div>
  </body>
</html>
Clone this wiki locally