move function deletenode() to the xml class

This commit is contained in:
rabuzarus 2016-11-27 20:19:43 +01:00
parent c96a53b4b4
commit 56e38dd6bd
3 changed files with 45 additions and 44 deletions

View file

@ -1,11 +1,12 @@
<?php
/**
* @file include/xml.php
*/
/**
* @brief This class contain functions to work with XML data
* @brief This class contain methods to work with XML data
*
*/
class xml {
@ -372,5 +373,18 @@ class xml {
return($xml_array);
}
/**
* @brief Delete a node in a XML object
*
* @param object $doc XML document
* @param string $node Node name
*/
public static function deleteNode(&$doc, $node) {
$xpath = new \DomXPath($doc);
$list = $xpath->query("//".$node);
foreach ($list as $child) {
$child->parentNode->removeChild($child);
}
}
}
?>