function AssertContentTrait::parse
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::parse()
- 10 core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::parse()
- 11.x 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\KernelTestsCode
protected function parse() {
if (!isset($this->elements)) {
// DOM can load HTML soup. But, HTML soup can throw warnings, suppress
// them.
$html_dom = new \DOMDocument();
@$html_dom->loadHTML('<?xml encoding="UTF-8">' . $this->getRawContent(), LIBXML_NOBLANKS);
if ($html_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($html_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.