You are here

public function QPXML::cdata in QueryPath 6

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

File

QueryPath/Extension/QPXML.php, line 21

Class

QPXML

Code

public function cdata($text = NULL) {
  if (isset($text)) {
    foreach ($this->qp
      ->get() as $element) {
      $cdata = $element->ownerDocument
        ->createCDATASection($text);
      $element
        ->appendChild($cdata);
    }
    return $this->qp;
  }
  foreach ($this->qp
    ->get() as $ele) {
    foreach ($ele->childNodes as $node) {
      if ($node->nodeType == XML_CDATA_SECTION_NODE) {
        return $node->textContent;
      }
    }
  }
  return NULL;
}