Heim >Backend-Entwicklung >PHP-Tutorial >PHP生成XML如何换行
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 "