FluentDOM\Element::applyNamespaces PHP Method

applyNamespaces() public method

Sets all namespaces registered on the document as xmlns attributes on the element.
public applyNamespaces ( null | string | array $prefixes = NULL )
$prefixes null | string | array
    public function applyNamespaces($prefixes = NULL)
    {
        if ($prefixes !== NULL && !is_array($prefixes)) {
            $prefixes = array($prefixes);
        }
        foreach ($this->getDocument()->namespaces() as $prefix => $namespace) {
            if (!$this->isCurrentNamespace($prefix, $namespace) && ($prefixes === NULL || in_array($prefix, $prefixes))) {
                $this->setAttribute($prefix === '#default' ? 'xmlns' : 'xmlns:' . $prefix, $namespace);
            }
        }
    }