You are here

function simple_html_dom_node::makeup in simplehtmldom API 5.2

Same name and namespace in other branches
  1. 6 simplehtmldom/simple_html_dom.php \simple_html_dom_node::makeup()
  2. 7 simplehtmldom/simple_html_dom.php \simple_html_dom_node::makeup()

File

simplehtmldom/simple_html_dom.php, line 229

Class

simple_html_dom_node

Code

function makeup() {

  // text, comment, unknown
  if (isset($this->_[HDOM_INFO_TEXT])) {
    return $this->dom
      ->restore_noise($this->_[HDOM_INFO_TEXT]);
  }
  $ret = '<' . $this->tag;
  $i = -1;
  foreach ($this->attr as $key => $val) {
    ++$i;

    // skip removed attribute
    if ($val === null || $val === false) {
      continue;
    }
    $ret .= $this->_[HDOM_INFO_SPACE][$i][0];

    //no value attr: nowrap, checked selected...
    if ($val === true) {
      $ret .= $key;
    }
    else {
      switch ($this->_[HDOM_INFO_QUOTE][$i]) {
        case HDOM_QUOTE_DOUBLE:
          $quote = '"';
          break;
        case HDOM_QUOTE_SINGLE:
          $quote = '\'';
          break;
        default:
          $quote = '';
      }
      $ret .= $key . $this->_[HDOM_INFO_SPACE][$i][1] . '=' . $this->_[HDOM_INFO_SPACE][$i][2] . $quote . $val . $quote;
    }
  }
  $ret = $this->dom
    ->restore_noise($ret);
  return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>';
}