WordPress at a glance
function is not described

WC_API_XML_Handler::generate_response() public WC 2.1

Generate an XML response given an array of data

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

Hooks from the method
Return

String.

Usage

$WC_API_XML_Handler = new WC_API_XML_Handler();
$WC_API_XML_Handler->generate_response( $data );
$data(array) (required)
the response data

Changelog

Since 2.1 Introduced.

Code of WC_API_XML_Handler::generate_response() WC 5.0.0

<?php
public function generate_response( $data ) {

	$this->xml = new XMLWriter();

	$this->xml->openMemory();

	$this->xml->setIndent( true );

	$this->xml->startDocument( '1.0', 'UTF-8' );

	$root_element = key( $data );

	$data = $data[ $root_element ];

	switch ( $root_element ) {

		case 'orders':
			$data = array( 'order' => $data );
			break;

		case 'order_notes':
			$data = array( 'order_note' => $data );
			break;

		case 'customers':
			$data = array( 'customer' => $data );
			break;

		case 'coupons':
			$data = array( 'coupon' => $data );
			break;

		case 'products':
			$data = array( 'product' => $data );
			break;

		case 'product_reviews':
			$data = array( 'product_review' => $data );
			break;

		default:
			$data = apply_filters( 'woocommerce_api_xml_data', $data, $root_element );
			break;
	}

	// generate xml starting with the root element and recursively generating child elements
	$this->array_to_xml( $root_element, $data );

	$this->xml->endDocument();

	return $this->xml->outputMemory();
}