PHP 和 XmlWriter 更改缩进字符串

PHP and XmlWriter change indent string

我正在使用 laravel 5 并尝试使用 XMLWRITER 输出 xml 文件。 是否可以将缩进字符串从 "one space" 更改为 "tabulation"?

我的实际代码:

    $xml = new \XMLWriter();
    $xml->openMemory();
    $xml->setIndent(4);
    $xml->startDocument('1.0','UTF-8','yes');
    $xml->startElement('immeuble');
    $xml->writeAttribute('nature-immeuble', 'test');
    $xml->startElement('adresse');
    $xml->writeAttribute('localite', 'Copropriete');
    $xml->writeAttribute('libelle-pays', 'France');
    $xml->startElement('cadastre');
        $xml->writeAttribute('section', 'AA');
        $xml->writeAttribute('numero', '0000');
        $xml->endElement();
        $xml->endElement();
    foreach($lots as $lot) {
        $xml->startElement('lot');
        $xml->writeAttribute('numero', $lot->id);
        $xml->writeAttribute('type', 'appartement');
        $designation = getDesignation2($lot->id);
        $xml->writeAttribute('designation', $designation);
        $xml->writeAttribute('batiment', substr($lot->etageLots->first()->etage->batiment->nom, 0, 5));
        $xml->writeAttribute('etage', $lot->etageLots->first()->etage->coeff_id);
        if(is_null($lot->tantieme_force)){
            $tantieme = round($lot->tantieme_calcul,0);
        }else{
            $tantieme = $lot->tantieme_force;
        }
        $xml->writeAttribute('milliemes-generaux', $tantieme.$base);
        $xml->endElement();
    }
    $xml->endElement();
    $xml->endDocument();

    $content = $xml->outputMemory();
    $xml = null;

    return response($content)->header('Content-Type', 'text/xml');

它给了我正确的 xml 但是每行都缩进了一个 space 实际上我想要一个表格。

是否可以更改此设置?

我看到了设置缩进字符串,但我没有找到将它与制表一起使用的方法。

感谢您的帮助。

如果你想缩进制表那么使用它:

$xml->setIndent(true);
$xml->setIndentString("\t");