You are here

protected function DefaultSitemapGenerator::getXml in Simple XML sitemap 8.3

Generates and returns a sitemap chunk.

Parameters

array $links: All links with their multilingual versions and settings.

Return value

string Sitemap chunk

Overrides SitemapGeneratorBase::getXml

File

src/Plugin/simple_sitemap/SitemapGenerator/DefaultSitemapGenerator.php, line 43

Class

DefaultSitemapGenerator
Class DefaultSitemapGenerator @package Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator

Namespace

Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator

Code

protected function getXml(array $links) {
  $this->writer
    ->openMemory();
  $this->writer
    ->setIndent(TRUE);
  $this->writer
    ->startSitemapDocument();

  // Add the XML stylesheet to document if enabled.
  if ($this->settings['xsl']) {
    $this->writer
      ->writeXsl();
  }
  $this->writer
    ->writeGeneratedBy();
  $this->writer
    ->startElement('urlset');
  $this
    ->addSitemapAttributes();
  $this
    ->addLinks($links);
  $this->writer
    ->endElement();
  $this->writer
    ->endDocument();
  return $this->writer
    ->outputMemory();
}