You are here

public function QPXML::pi in QueryPath 6

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

File

QueryPath/Extension/QPXML.php, line 64

Class

QPXML

Code

public function pi($prefix = NULL, $text = NULL) {
  if (isset($text)) {
    foreach ($this->qp
      ->get() as $element) {
      $comment = $element->ownerDocument
        ->createProcessingInstruction($prefix, $text);
      $element
        ->appendChild($comment);
    }
    return $this->qp;
  }
  foreach ($this->qp
    ->get() as $ele) {
    foreach ($ele->childNodes as $node) {
      if ($node->nodeType == XML_PI_NODE) {
        if (isset($prefix)) {
          if ($node->tagName == $prefix) {
            return $node->textContent;
          }
        }
        else {
          return $node->textContent;
        }
      }
    }
  }
}