PHP生成XML如何换行
程序员文章站
2022-06-11 19:05:31
...
PHP生成XML怎么换行?
foreach ($data as $k) {
$add = $dom->createElement('add');
$add=$root->appendChild($add);
$name = $dom->createAttribute("name");
$name=$add->appendChild($name);
$nameValue = $dom->createTextNode($k[0]);
$name->appendChild($nameValue);
$drivers=$dom->createAttribute("providerName");
$drivers=$add->appendChild($drivers);
$driversvalue=$dom->createTextNode($k[1]);
$drivers->appendChild($driversvalue);
$connectionstring="Data Source=".$k[2].";Initial Catalog=".$k[3].";Persist Security Info=True;User ID=".$k[4].";Password=".$k[5].";MAX Pool Size=2000;Min Pool Size=3;Connection Lifetime=30;Pooling=true;charset=utf8;";
$connstring=$dom->createAttribute("connectionString");
$connstring=$add->appendChild($connstring);
$connstringvalue=$dom->createTextNode($connectionstring);
$connstring->appendChild($connstringvalue);
}
$output = $dom->saveXML();
echo "".$output." ";
}
PHP生成的XML在页面上显示不换行,怎么让它换行呢?
页面显示结果如下:
foreach ($data as $k) {
$add = $dom->createElement('add');
$add=$root->appendChild($add);
$name = $dom->createAttribute("name");
$name=$add->appendChild($name);
$nameValue = $dom->createTextNode($k[0]);
$name->appendChild($nameValue);
$drivers=$dom->createAttribute("providerName");
$drivers=$add->appendChild($drivers);
$driversvalue=$dom->createTextNode($k[1]);
$drivers->appendChild($driversvalue);
$connectionstring="Data Source=".$k[2].";Initial Catalog=".$k[3].";Persist Security Info=True;User ID=".$k[4].";Password=".$k[5].";MAX Pool Size=2000;Min Pool Size=3;Connection Lifetime=30;Pooling=true;charset=utf8;";
$connstring=$dom->createAttribute("connectionString");
$connstring=$add->appendChild($connstring);
$connstringvalue=$dom->createTextNode($connectionstring);
$connstring->appendChild($connstringvalue);
}
$output = $dom->saveXML();
echo "
}
PHP生成的XML在页面上显示不换行,怎么让它换行呢?
页面显示结果如下: