PHP XML如何输出漂亮的格式
以下是代码:
$doc = new DomDocument('1.0');// create root node$root = $doc->createElement('root');$root = $doc->appendChild($root);$signed_values = array('a' => 'eee', 'b' => 'sd', 'c' => 'df');// process one row at a timeforeach ($signed_values as $key => $val) { // add node for each row $occ = $doc->createElement('error'); $occ = $root->appendChild($occ); // add a child node for each field foreach ($signed_values as $fieldname => $fieldvalue) { $child = $doc->createElement($fieldname); $child = $occ->appendChild($child); $value = $doc->createTextNode($fieldvalue); $value = $child->appendChild($value); }}// get completed xml document$xml_string = $doc->saveXML() ;echo $xml_string;
如果我在浏览器中打印它,我就不会得到很好的XML结构
<xml> \n tab <child> etc.
我得到了
<xml><child>ee</child></xml>
我想成为utf-8这一切都有可能吗?
UYOU
一只斗牛犬