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
Namespace
TheSeer\TokenizerCode
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();
}