我写了这段代码:
XmlTextWriter^ w = gcnew XmlTextWriter( fs, nullptr );
w->WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");
w->WriteStartElement("healing");
w->WriteStartElement("health1");
w->WriteElementString("value", "100");
w->WriteElementString("hotkey", "2");
w->WriteElementString("enable", "0");
w->WriteEndElement();
w->WriteStartElement("health2");
w->WriteElementString("value", "100");
w->WriteElementString("hotkey", "2");
w->WriteElementString("enable", "0");
w->WriteEndElement();
w->WriteStartElement("health3");
w->WriteElementString("value", "100");
w->WriteElementString("hotkey", "2");
w->WriteElementString("enable", "0");
w->WriteEndElement();
w->WriteStartElement("mana");
w->WriteElementString("value", "100");
w->WriteElementString("hotkey", "2");
w->WriteElementString("enable", "0");
w->WriteEndElement();
w->WriteEndElement();
w->Flush();
w->Close();
但它创建的 XML 看起来并不漂亮,没有输入,选项卡等:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><healing><health1><value>100</value><hotkey>2</hotkey><enable>0</enable></health1><health2><value>100</value><hotkey>2</hotkey><enable>0</enable></health2><health3><value>100</value><hotkey>2</hotkey><enable>0</enable></health3><mana><value>100</value><hotkey>2</hotkey><enable>0</enable></mana></healing>
我怎样才能让它看起来很漂亮?