You are here

public function QueryPath::html in QueryPath 6

Same name and namespace in other branches
  1. 7.3 QueryPath/QueryPath.php \QueryPath::html()
  2. 7.2 QueryPath/QueryPath.php \QueryPath::html()

File

QueryPath/QueryPath.php, line 1139

Class

QueryPath

Code

public function html($markup = NULL) {
  if (isset($markup)) {
    if ($this->options['replace_entities']) {
      $markup = QueryPathEntities::replaceAllEntities($markup);
    }
    $doc = $this->document
      ->createDocumentFragment();
    $doc
      ->appendXML($markup);
    $this
      ->removeChildren();
    $this
      ->append($doc);
    return $this;
  }
  $length = $this
    ->size();
  if ($length == 0) {
    return NULL;
  }
  $first = $this
    ->getFirstMatch();
  if (!$first instanceof DOMNode) {
    return NULL;
  }
  if (!$first->ownerDocument->documentElement) {
    return NULL;
  }
  if ($first instanceof DOMDocument || $first
    ->isSameNode($first->ownerDocument->documentElement)) {
    return $this->document
      ->saveHTML();
  }
  return $this->document
    ->saveXML($first);
}