How to display XML output for API call

I have a plugin to override web_services plugin and want to output my API result in XML format in addition to JSON (default) and CSV. I added below code to mod/my_plugin/views/xml/api/output.php file

$result = $vars['result'];

$export = $result->export();

echo serialize_object_to_xml($export);

function serialize_object_to_xml($data) {

      $serializer_options = array ( 'addDecl' => FALSE, 'encoding' => 'UTF-8', 'indent' => ' '); 

     $Serializer = new XML_Serializer($serializer_options);

     $Serializer->serialize($data); 

     return $Serializer->getSerializedData();

}

I use PEAR-1.10.10, XML_Serializer-0.21.0, XML_Parser-1.3.8, and XML_Util-1.4.4 to serialize data to XML format. I put these libraries in mod/my_plugin/vendors directory and added below lines in init function inside my plugin

set_include_path(elgg_get_plugins_path() . "my_plugin/vendors/XML_Serializer-0.21.0" . PATH_SEPARATOR . get_include_path() ); 

set_include_path(elgg_get_plugins_path() . "my_plugin/vendors/PEAR-1.10.10" . PATH_SEPARATOR . get_include_path() ); 

set_include_path(elgg_get_plugins_path() . "my_plugin/vendors/XML_Util-1.4.4" . PATH_SEPARATOR . get_include_path() ); 

set_include_path(elgg_get_plugins_path() . "my_plugin/vendors/XML_Parser-1.3.8" . PATH_SEPARATOR . get_include_path() ); 

Configurations above works with my Elgg2.3* site BUT not with Elgg3.3.2. My server currently uses PHP7.3.16.

Did I miss anything on my configurations for Elgg3.3.2?

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking