下面这段代码如何让xml节点换行?
原始的XML
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book id="B01">
<name>哈里波特</name>
<price>15</price>
<memo>这是一本很好看的书。</memo>
</book>
<book id="B02">
<name>水浒</name>
<price>6</price>
<memo>四大名著之一。</memo>
</book>
</books>修改后的XML
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book id="B01">
<name>哈里波特</name>
<price>15</price>
<memo>这是一本很好看的书。</memo>
</book>
<book id="B02">
<name>水浒</name>
<price>6</price>
<memo>四大名著之一。</memo>
</book>
<book><name>新书</name><price>20</price><memo>好看的新书。</memo></book></books>
C++代码如下
void CMyXMLDlg::OnBnClickedButtonAdd()
{
CoInitialize(NULL);
CComPtr<IXMLDOMDocument> spXmldoc; //DOM
spXmldoc.CoCreateInstance(CLSID_DOMDocument);
VARIANT_BOOL vb;
CComVariant varXmlFile(L"C:\\MyXML.xml");
spXmldoc->put_async(VARIANT_FALSE);
spXmldoc->load(varXmlFile, &vb); //加载XML文件
CComBSTR bstrXml;
CComPtr<IXMLDOMElement> spRoot;
spXmldoc->get_documentElement(&spRoot);
spRoot->get_xml(&bstrXml); //加载原始的XML
//AfxMessageBox(bstrXml); CComPtr<IXMLDOMElement> spBook;
CComPtr<IXMLDOMElement> spElem;
CComPtr<IXMLDOMNode> spNode;


spXmldoc->createElement(L"book", &spBook);
spXmldoc->createElement(L"name", &spElem);
spElem->put_text(L"新书");
spBook->appendChild(spElem, &spNode);
spElem.Release();
spNode.Release(); spXmldoc->createElement(L"price", &spElem);
spElem->put_text(L"20");
spBook->appendChild(spElem, &spNode);
spElem.Release();
spNode.Release(); spXmldoc->createElement(L"memo", &spElem);
spElem->put_text(L"好看的新书。");
spBook->appendChild(spElem, &spNode);
spNode.Release();
spElem.Release();

spRoot->appendChild(spBook, &spNode);
spNode.Release();
spBook.Release(); spRoot->get_xml(&bstrXml);
AfxMessageBox(bstrXml); //增加节点完成
//spXmldoc->save(varXmlFile); //保存xml。
varXmlFile.ClearToZero();}