# _oembed_create_xml()

URL: https://chugunov.pro/api-wordpress/functions/_oembed_create_xml/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 4.4.0.

## Сигнатура

```php
_oembed_create_xml( array $data, SimpleXMLElement $node = null ): string|false
```

## Описание

Создаёт XML-строку из заданного массива.

## Параметры

- `$data` `array` — обязательный. Исходные данные ответа oEmbed.
- `$node` `SimpleXMLElement` — необязательный, по умолчанию `null`. XML-узел, к которому рекурсивно добавляется результат.

## Возвращаемое значение

`string|false`

## Исходный код

Файл: `wp-includes/embed.php:828`

```php
function _oembed_create_xml( $data, $node = null ) {
	if ( ! is_array( $data ) || empty( $data ) ) {
		return false;
	}

	if ( null === $node ) {
		$node = new SimpleXMLElement( '<oembed></oembed>' );
	}

	foreach ( $data as $key => $value ) {
		if ( is_numeric( $key ) ) {
			$key = 'oembed';
		}

		if ( is_array( $value ) ) {
			$item = $node->addChild( $key );
			_oembed_create_xml( $value, $item );
		} else {
			$node->addChild( $key, esc_html( $value ) );
		}
	}

	return $node->asXML();
}
```

## История изменений

- 4.4.0 — Introduced.

## Связанные

Использует: [`_oembed_create_xml`](https://chugunov.pro/api-wordpress/functions/_oembed_create_xml/), [`esc_html`](https://chugunov.pro/api-wordpress/functions/esc_html/).
Используется в: [`_oembed_rest_pre_serve_request`](https://chugunov.pro/api-wordpress/functions/_oembed_rest_pre_serve_request/), [`_oembed_create_xml`](https://chugunov.pro/api-wordpress/functions/_oembed_create_xml/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/_oembed_create_xml/
