You are here

public function ReportEditor::deleteNode in Forena Reports 8

Same name and namespace in other branches
  1. 7.5 src/Editor/ReportEditor.php \Drupal\forena\Editor\ReportEditor::deleteNode()

Delete a node based on id

Parameters

string $id:

Return value

ReportEditor

File

src/Editor/ReportEditor.php, line 820
ReportEditor.inc Wrapper XML class for working with DOM object. It provides helper Enter description here ... @author metzlerd

Class

ReportEditor

Namespace

Drupal\forena\Editor

Code

public function deleteNode($id) {
  $path = 'body//*[@id="' . $id . '"]';
  $nodes = $this->simplexml
    ->xpath($path);
  if ($nodes) {
    $node = $nodes[0];
    $dom = dom_import_simplexml($node);
    $dom->parentNode
      ->removeChild($dom);
  }
  return $this;
}