function AssertContentTrait::parse

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::parse()
  2. 8.9.x core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::parse()
  3. 10 core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::parse()

Parse content returned from curlExec using DOM and SimpleXML.

Return value

\SimpleXMLElement|false A SimpleXMLElement or FALSE on failure.

1 call to AssertContentTrait::parse()
AssertContentTrait::xpath in core/tests/Drupal/KernelTests/AssertContentTrait.php
Performs an xpath search on the contents of the internal browser.

File

core/tests/Drupal/KernelTests/AssertContentTrait.php, line 123

Class

AssertContentTrait
Provides test methods to assert content.

Namespace

Drupal\KernelTests

Code

protected function parse() {
    if (!isset($this->elements)) {
        $content = $this->getRawContent();
        $dom = Html::load($content);
        if ($dom) {
            // It's much easier to work with simplexml than DOM, luckily enough
            // we can just simply import our DOM tree.
            $this->elements = @simplexml_import_dom($dom);
        }
    }
    $this->assertNotFalse($this->elements, 'The current HTML page should be available for DOM navigation.');
    return $this->elements;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.