Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. XMLSerializer.php

function XMLSerializer::toXML

1 call to XMLSerializer::toXML()
XMLSerializer::toDom in vendor/theseer/tokenizer/src/XMLSerializer.php

File

vendor/theseer/tokenizer/src/XMLSerializer.php, line 37

Class

XMLSerializer

Namespace

TheSeer\Tokenizer

Code

public function toXML(TokenCollection $tokens) : string {
    $this->writer = new \XMLWriter();
    $this->writer
        ->openMemory();
    $this->writer
        ->setIndent(true);
    $this->writer
        ->startDocument();
    $this->writer
        ->startElement('source');
    $this->writer
        ->writeAttribute('xmlns', $this->xmlns
        ->asString());
    if (\count($tokens) > 0) {
        $this->writer
            ->startElement('line');
        $this->writer
            ->writeAttribute('no', '1');
        $this->previousToken = $tokens[0];
        foreach ($tokens as $token) {
            $this->addToken($token);
        }
    }
    $this->writer
        ->endElement();
    $this->writer
        ->endElement();
    $this->writer
        ->endDocument();
    return $this->writer
        ->outputMemory();
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal