src/Sanitizer.php
protected function startClean(\DOMNodeList $elements)
    {
        // loop through all elements
        // we do this backwards so we don't skip anything if we delete a node
        // see comments at: http://php.net/manual/en/class.domnamednodemap.php
        for ($i = $elements->length - 1; $i >= 0; $i--) {
            $currentElement = $elements->item($i);

            // If the tag isn't in the whitelist, remove it and continue with next iteration
            if (!in_array(strtolower($currentElement->tagName), $this->allowedTags)) {
                $currentElement->parentNode->removeChild($currentElement);
                $this->xmlIssues[] = array(
                    'message' => 'Suspicious tag \'' . $currentElement->tagName . '\'',
                    'line' => $currentElement->getLineNo(),
		);
                continue;
            }

            $this->cleanAttributesOnWhitelist($currentElement);

            $this->cleanXlinkHrefs($currentElement);

            $this->cleanHrefs($currentElement);

            if (strtolower($currentElement->tagName) === 'use') {
                if ($this->isUseTagDirty($currentElement)) {
                    $currentElement->parentNode->removeChild($currentElement);
                    $this->xmlIssues[] = array(
                        'message' => 'Suspicious \'' . $currentElement->tagName . '\'',
			'line' => $currentElement->getLineNo(),
                    );
                    continue;
                }
            }
        }
    }
protected function startClean(\DOMNodeList $elements)
    {
        // loop through all elements
        // we do this backwards so we don't skip anything if we delete a node
        // see comments at: http://php.net/manual/en/class.domnamednodemap.php
        for ($i = $elements->length - 1; $i >= 0; $i--) {
            $currentElement = $elements->item($i);

            // If the tag isn't in the whitelist, remove it and continue with next iteration
            if (!in_array(strtolower($currentElement->tagName), $this->allowedTags)) {
                $currentElement->parentNode->removeChild($currentElement);
                $this->xmlIssues[] = array(
                    'message' => 'Suspicious tag \'' . $currentElement->tagName . '\'',
                    'line' => $currentElement->getLineNo(),
		);
                continue;
            }

            $this->cleanAttributesOnWhitelist($currentElement);

            $this->cleanXlinkHrefs($currentElement);

            $this->cleanHrefs($currentElement);

            if (strtolower($currentElement->tagName) === 'use') {
                if ($this->isUseTagDirty($currentElement)) {
                    $currentElement->parentNode->removeChild($currentElement);
                    $this->xmlIssues[] = array(
                        'message' => 'Suspicious \'' . $currentElement->tagName . '\'',
			'line' => $currentElement->getLineNo(),
                    );
                    continue;
                }
            }
        }
    }
protected function startClean ( \ DOMNodeList $ elements ) { // loop through all elements // we do this backwards so we don't skip anything if we delete a node // see comments at: http://php.net/manual/en/class.domnamednodemap.php for ( $ i = $ elements -> length - 1 ; $ i >= 0 ; $ i -- ) { $ currentElement = $ elements -> item ( $ i ) ; // If the tag isn't in the whitelist, remove it and continue with next iteration if ( ! in_array ( strtolower ( $ currentElement -> tagName ) , $ this -> allowedTags ) ) { $ currentElement -> parentNode -> removeChild ( $ currentElement ) ; $ this -> xmlIssues [ ] = array ( 'message' => 'Suspicious tag \'' . $ currentElement -> tagName . '\'' , 'line' => $ currentElement -> getLineNo ( ) , ) ; continue ; } $ this -> cleanAttributesOnWhitelist ( $ currentElement ) ; $ this -> cleanXlinkHrefs ( $ currentElement ) ; $ this -> cleanHrefs ( $ currentElement ) ; if ( strtolower ( $ currentElement -> tagName ) === 'use' ) { if ( $ this -> isUseTagDirty ( $ currentElement ) ) { $ currentElement -> parentNode -> removeChild ( $ currentElement ) ; $ this -> xmlIssues [ ] = array ( 'message' => 'Suspicious \'' . $ currentElement -> tagName . '\'' , 'line' => $ currentElement -> getLineNo ( ) , ) ; continue ; } } } }
Start the cleaning with tags, then we move onto attributes and hrefs later

@param \DOMNodeList $elements
Start the cleaning with tags then we move onto attributes and hrefs later