Altova Mailing List Archives
>microsoft.public.xml Archive Home
>Thread Prev - Re: How to save a XML DOM object into a string buffer.
>Thread Next - Re: How to save a XML DOM object into a string buffer.
Re: How to save a XML DOM object into a string buffer.
Date: 7/11/2006 7:01:00 AM
"Anthony Jones" wrote: > > "jim" <jim@d...> wrote in message > news:1A51E4D4-7A87-4FD6-8B52-481CB8CA24F1@m...... > > Hi All, > > > > I used MSXML DOM 4 to manipulate XML document and tried to save an XML DOM > > object into a memory buffer. There are two methods in MSXML to get the > whole > > XML content from XML DOM object: > > > > 1) save method to save to an file. it also keeps the original encoding. > > 2) xml property. But it will remove the original encoding information. > > > > My question is: how can I save the whole XML content of XML DOM into a > > memory buffer with its original encoding information? > > > > If above method 1) were used, then writing/reading file operatin have to > be > > taken. If 2) method were used, the original encoding will be lost. > > > > Anybody can provide idea would be greate appreciated. > > > > Use IStream implementation that stores the stream in memory. You can either > build your own or use CreateStreamOnHGlobal to create a stream on memory > allocated by GlobalAlloc (although you need to be sure to allocate a buffer > big enough which is a bit challange to determine) > > Another alternative would be to write to an ADODB.Stream object. > > What do you want to do with the xml document in memory anyway? > Anthony --- Thanks for your immediately reply! I have to pass the content of the xml document to another program module through its original interface which it only accepts the _TCHAR* parameter. So I have to allocate the buffer to put into the xml content to it and try to keep the xml doc no any change. Unfortunately, xml property of MSXML DOM object will chagend or removed xml doc original endoing. Jim