You are here

public function Report::deleteNode in Forena Reports 8

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

Delete a node based on id

Parameters

string $id:

File

src/Report.php, line 456
Basic report provider. Controls the rendering of the report.

Class

Report

Namespace

Drupal\forena

Code

public function deleteNode($id) {
  $path = 'body//*[@id="' . $id . '"]';
  $nodes = $this->rpt_xml
    ->xpath($path);
  if ($nodes) {

    /** @var \SimpleXMLElement $node */
    $node = $nodes[0];
    $dom = dom_import_simplexml($node);
    $dom->parentNode
      ->removeChild($dom);
  }
}