WordPress at a glance
function is not described

WP_Sitemaps_Renderer::get_sitemap_index_xml() public WP 5.5.0

Gets XML for a sitemap index.

{} It's a method of the class: WP_Sitemaps_Renderer{}

No Hooks.

Return

String/false. A well-formed XML string for a sitemap index. False on error.

Usage

$WP_Sitemaps_Renderer = new WP_Sitemaps_Renderer();
$WP_Sitemaps_Renderer->get_sitemap_index_xml( $sitemaps );
$sitemaps(array) (required)
Array of sitemap URLs.

Changelog

Since 5.5.0 Introduced.

Code of WP_Sitemaps_Renderer::get_sitemap_index_xml() WP 5.5.1

<?php
public function get_sitemap_index_xml( $sitemaps ) {
	$sitemap_index = new SimpleXMLElement(
		sprintf(
			'%1$s%2$s%3$s',
			'<?xml version="1.0" encoding="UTF-8" ?>',
			$this->stylesheet_index,
			'<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />'
		)
	);

	foreach ( $sitemaps as $entry ) {
		$sitemap = $sitemap_index->addChild( 'sitemap' );

		// Add each element as a child node to the <sitemap> entry.
		foreach ( $entry as $name => $value ) {
			if ( 'loc' === $name ) {
				$sitemap->addChild( $name, esc_url( $value ) );
			} elseif ( 'lastmod' === $name ) {
				$sitemap->addChild( $name, esc_xml( $value ) );
			} else {
				_doing_it_wrong(
					__METHOD__,
					sprintf(
						/* translators: %s: List of element names. */
						__( 'Fields other than %s are not currently supported for the sitemap index.' ),
						implode( ',', array( 'loc', 'lastmod' ) )
					),
					'5.5.0'
				);
			}
		}
	}

	return $sitemap_index->asXML();
}