关于XML文件换行和缩进的问题,谢谢
大家好,我在写XML文件的时候,输入如下代码:
MSXML2::IXMLDOMDocumentPtr pDoc;
MSXML2::IXMLDOMElementPtr xmlRoot ;
MSXML2::IXMLDOMProcessingInstructionPtr pPI=NULL;
HRESULT hr =CoInitialize(NULL);
hr = pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument30));
pDoc->raw_createProcessingInstruction(_bstr_t(L"xml"),_bstr_t(L"version='1.0' encoding='GB2312'"),&pPI);
pDoc->appendChild(pPI);
//创建Element对象 作为根节点
MSXML2::IXMLDOMElementPtr pDocElement=pDoc->createElement("China");
//把根节点插入到目录树中
pDoc->appendChild(pDocElement);
MSXML2::IXMLDOMElementPtr pNewChildElement;
pNewChildElement=pDoc->createElement("Beijing");
pNewChildElement->Puttext("-11");
pDocElement->appendChild(pNewChildElement);
pNewChildElement=pDoc->createElement("Shanghai");
pNewChildElement->Puttext("9");
pNewChildElement->setAttribute("Weather",_variant_t("Cloudy"));
pDocElement->appendChild(pNewChildElement);
pDoc->save("d:\\vity.xml");
但是读出来的XML文件没有换行和缩进,排成一排,请问如何换行。
谢谢。