Altova Mailing List Archives

Re: How to save a XML DOM object into a string buffer.

From: jim@-----------.---------.---
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.



These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.