public function startElement($name): bool
    {
        if ('{' === $name[0]) {
            list($namespace, $localName) =
                Service::parseClarkNotation($name);

            if (array_key_exists($namespace, $this->namespaceMap)) {
                $result = $this->startElementNS(
                    '' === $this->namespaceMap[$namespace] ? null : $this->namespaceMap[$namespace],
                    $localName,
                    null
                );
            } else {
                // An empty namespace means it's the global namespace. This is
                // allowed, but it mustn't get a prefix.
                if ('' === $namespace || null === $namespace) {
                    $result = $this->startElement($localName);
                    $this->writeAttribute('xmlns', '');
                } else {
                    if (!isset($this->adhocNamespaces[$namespace])) {
                        $this->adhocNamespaces[$namespace] = 'x'.(count($this->adhocNamespaces) + 1);
                    }
                    $result = $this->startElementNS($this->adhocNamespaces[$namespace], $localName, $namespace);
                }
            }
        } else {
            $result = parent::startElement($name);
        }

        if (!$this->namespacesWritten) {
            foreach ($this->namespaceMap as $namespace => $prefix) {
                $this->writeAttribute(($prefix ? 'xmlns:'.$prefix : 'xmlns'), $namespace);
            }
            $this->namespacesWritten = true;
        }

        return $result;
    }
public function startElement($name): bool
    {
        if ('{' === $name[0]) {
            list($namespace, $localName) =
                Service::parseClarkNotation($name);

            if (array_key_exists($namespace, $this->namespaceMap)) {
                $result = $this->startElementNS(
                    '' === $this->namespaceMap[$namespace] ? null : $this->namespaceMap[$namespace],
                    $localName,
                    null
                );
            } else {
                // An empty namespace means it's the global namespace. This is
                // allowed, but it mustn't get a prefix.
                if ('' === $namespace || null === $namespace) {
                    $result = $this->startElement($localName);
                    $this->writeAttribute('xmlns', '');
                } else {
                    if (!isset($this->adhocNamespaces[$namespace])) {
                        $this->adhocNamespaces[$namespace] = 'x'.(count($this->adhocNamespaces) + 1);
                    }
                    $result = $this->startElementNS($this->adhocNamespaces[$namespace], $localName, $namespace);
                }
            }
        } else {
            $result = parent::startElement($name);
        }

        if (!$this->namespacesWritten) {
            foreach ($this->namespaceMap as $namespace => $prefix) {
                $this->writeAttribute(($prefix ? 'xmlns:'.$prefix : 'xmlns'), $namespace);
            }
            $this->namespacesWritten = true;
        }

        return $result;
    }
public function startElement ( $ name ) : bool { if ( '{' === $ name [ 0 ] ) { list ( $ namespace , $ localName ) = Service :: parseClarkNotation ( $ name ) ; if ( array_key_exists ( $ namespace , $ this -> namespaceMap ) ) { $ result = $ this -> startElementNS ( '' === $ this -> namespaceMap [ $ namespace ] ? null : $ this -> namespaceMap [ $ namespace ] , $ localName , null ) ; } else { // An empty namespace means it's the global namespace. This is // allowed, but it mustn't get a prefix. if ( '' === $ namespace || null === $ namespace ) { $ result = $ this -> startElement ( $ localName ) ; $ this -> writeAttribute ( 'xmlns' , '' ) ; } else { if ( ! isset ( $ this -> adhocNamespaces [ $ namespace ] ) ) { $ this -> adhocNamespaces [ $ namespace ] = 'x' . ( count ( $ this -> adhocNamespaces ) + 1 ) ; } $ result = $ this -> startElementNS ( $ this -> adhocNamespaces [ $ namespace ] , $ localName , $ namespace ) ; } } } else { $ result = parent :: startElement ( $ name ) ; } if ( ! $ this -> namespacesWritten ) { foreach ( $ this -> namespaceMap as $ namespace => $ prefix ) { $ this -> writeAttribute ( ( $ prefix ? 'xmlns:' . $ prefix : 'xmlns' ) , $ namespace ) ; } $ this -> namespacesWritten = true ; } return $ result ; }
Opens a new element.

You can either just use a local elementname, or you can use clark-
notation to start a new element.

Example:

$writer->startElement('{http://www.w3.org/2005/Atom}entry');

Would result in something like:

<entry xmlns="http://w3.org/2005/Atom">

Note: this function doesn't have the string typehint, because PHP's
XMLWriter::startElement doesn't either.

@param string $name
Opens a new element .