c++ - how can i store xml in buffer using xmlite? -
I am trying to write XML data on buffer XML data but no API was found. Writing an XML file works fine but on the memory stream I can not understand that I am working on the follwong link API
Then you can use it or create a memory stream. The sample code for your reference is here:
CComPtr < IStream & gt; SpMemoryStream; CComPtr & LT; IXmlWriter & gt; SpWriter; CComPtr & LT; IXmlWriterOutput & gt; PWriterOutput; // Writing output stream opens SpMemoryStream.Attach (:: SHCreateMemStream (zero, 0)); If (spMemoryStream == faucet) back E_OUTOFMEMORY; // XML creator creates and generates content. CHKHR (:: EXPLOREXLLER (__UUIDOF (IXMLERIT), (Zero **) and SPWRITER, NULL); CHKHR (:: XMLRUTUtputUptut Encoding Name (Spammerstream, Nouel, L "UTF-16", and PWRIUUTUP)); CHKHR (spWriter-> SetOutput (pWriterOutput)); CHKHR (Spatium-> Setproperty (XMLRPProperty-Indent, True)); CHKHR (spWriter-> WriteStartDocument (XmlStandalone_Omit)); CHKHR (Spermicator-> ListStart Element (NULL, L "Route", NULL); CHKHR (spWriter-> WriteWhitespace (L "\ n")); CHKHR (spWriter-> WriteCData (L "This is CATA Text.")); CHKHR (spWriter-> WriteWhitespace (L "\ n")); CHKHR (spWriter-> WriteEndDocument ()); CHKHR (spWriter-> Flush ()); // XML allocates adequate memorial for content STATSTG ssStreamData = {0}; CHKHR (Spammerstream-> State (and SSStream Data, STATFLAG_NONAME); SIZE_T cbSize = ssStreamData.cbSize.LowPart; LPWSTR pwszContent = (WCHAR *) new (std :: nothrow) BYTE [cbSize + sizeof (WCHAR)]; If (pwszContent == NULL) back E_OUTOFMEMORY; // Copy buffer content from the stream LARGE_INTEGER's status; Event. QuadPart = 0; CHKHR (Spammerstream-> Sequence (status, STREAM_SEEK_SET, NULL)); SIZE_T cbRead; CHKHR (Spammerstream-> Reed (PWS content, CBSEs, and CB read)); PwszContent [cbSize / sizeof (WCHAR)] = 'L' \ 0 '; Wprintf (L "% s", pwszContent);
A good thing about XmlLite is that it works with the Interface interface. It does not really care what the stream behind the scene looks exactly.
Comments
Post a Comment