来自具有缩进的对象/数组的PHP XML序列化(替换pear / XML_serializer)

pear/XML_Serializer can take indent parameter which will be used as indentation character(to get human readable, well formatted XML)

I am trying to find a replacement for this package, but no one has similar feature.

Can someone advise a solution? Thanks in advance.

Symfony/Serializer can do that with xml_format_output

use \Symfony\Component\Serializer\Serializer;
use \Symfony\Component\Serializer\Encoder\XmlEncoder;
$serializer = new Serializer(array(), new XmlEncoder());
$array = array('your' => 'data');
echo $serializer->serialize($array, 'xml', array('xml_format_output' => true));