You are here

public function QueryPath::append in QueryPath 6

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

File

QueryPath/QueryPath.php, line 633

Class

QueryPath

Code

public function append($data) {
  $data = $this
    ->prepareInsert($data);
  if (isset($data)) {
    if (empty($this->document->documentElement) && $this->matches
      ->count() == 0) {
      $this->document
        ->appendChild($data);
      $found = new SplObjectStorage();
      $found
        ->attach($this->document->documentElement);
      $this
        ->setMatches($found);
    }
    else {
      foreach ($this->matches as $m) {
        if ($data instanceof DOMDocumentFragment) {
          foreach ($data->childNodes as $n) {
            $m
              ->appendChild($n
              ->cloneNode(TRUE));
          }
        }
        else {
          $m
            ->appendChild($data
            ->cloneNode(TRUE));
        }
      }
    }
  }
  return $this;
}