Skip to content

Instantly share code, notes, and snippets.

@hirosof
Created August 6, 2013 15:55
Show Gist options
  • Select an option

  • Save hirosof/6165814 to your computer and use it in GitHub Desktop.

Select an option

Save hirosof/6165814 to your computer and use it in GitHub Desktop.
#define WIN32_LEAN_AND_MEAN
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
#include <atlbase.h> // CComPtrを使用するため
#include <xmllite.h>
#pragma comment(lib, "xmllite.lib")
#include <stdio.h>
#include <Windows.h>
#include <windowsx.h>
int main(void){
CComPtr<IXmlWriter> pWriter;
CComPtr<IStream> pStream;
SHCreateStreamOnFile(_T("xmllite_write.xml") , STGM_READWRITE | STGM_CREATE , &pStream);
CreateXmlWriter(__uuidof(IXmlWriter) , reinterpret_cast<void**>(&pWriter) , 0);
pWriter->SetOutput(pStream);
pWriter->SetProperty(XmlWriterProperty_Indent , TRUE);
pWriter->WriteStartDocument(XmlStandalone_Yes);
pWriter->WriteStartElement(NULL, L"test" , NULL);
{
pWriter->WriteStartElement(NULL , L"indata" , NULL);
pWriter->WriteString(L"文字列");
pWriter->WriteEndElement();
}
pWriter->WriteEndElement();
pWriter->WriteEndDocument();
pWriter->Flush();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment