DrupalWebTestCase::parse

  1. drupal
    1. 8
    2. 7
Versions
7 protected DrupalWebTestCase::parse()

Parse content returned from curlExec using DOM and SimpleXML.

Return value

A SimpleXMLElement or FALSE on failure.

Code

modules/simpletest/drupal_web_test_case.php, line 1680

<?php
protected function parse() {
  if (!$this->elements) {
    // DOM can load HTML soup. But, HTML soup can throw warnings, suppress
    // them.
    $htmlDom = new DOMDocument();
    @$htmlDom->loadHTML($this->drupalGetContent());
    if ($htmlDom) {
      $this->pass(t('Valid HTML found on "@path"', array('@path' => $this->getUrl())), t('Browser'));
      // 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($htmlDom);
    }
  }
  if (!$this->elements) {
    $this->fail(t('Parsed page successfully.'), t('Browser'));
  }

  return $this->elements;
}
?>