Box\Spout\Reader\Wrapper\SimpleXMLElement::removeNodesMatchingXPath PHP Method

removeNodesMatchingXPath() public method

It does not map to any \SimpleXMLElement function.
public removeNodesMatchingXPath ( string $path ) : void
$path string An XPath path
return void
    public function removeNodesMatchingXPath($path)
    {
        $nodesToRemove = $this->simpleXMLElement->xpath($path);
        foreach ($nodesToRemove as $nodeToRemove) {
            unset($nodeToRemove[0]);
        }
    }

Usage Example

Example #1
0
 /**
  * Removes nodes that should not be read, like the pronunciation of the Kanji characters.
  * By keeping them, their text content would be added to the read string.
  *
  * @param \Box\Spout\Reader\Wrapper\SimpleXMLElement $parentNode Parent node that may contain nodes to remove
  * @return \Box\Spout\Reader\Wrapper\SimpleXMLElement Cleaned parent node
  */
 protected function removeSuperfluousTextNodes($parentNode)
 {
     $tagsToRemove = ['rPh', 'pPr', 'rPr'];
     foreach ($tagsToRemove as $tagToRemove) {
         $xpath = '//ns:' . $tagToRemove;
         $parentNode->removeNodesMatchingXPath($xpath);
     }
     return $parentNode;
 }
All Usage Examples Of Box\Spout\Reader\Wrapper\SimpleXMLElement::removeNodesMatchingXPath