I'm not sure why. The other person that worked on the project used it when he read the xml. He's very clever so I thought it would be the right thing to do :-)
I have a xmlfile in a byte array that I copy to pInBuffer using GlobalAllco/GlobalLock. Then I read throught the xml, make some changes and want to get it back into a byte array to use elsewhere.
Like I said I'm new :-) I still have pOutBuffer. Tried to do (byte*) pOutBuffer -> no luck.
Your example confusingly declares an IXmlReader as outStream, you really should call it inStream.
The code you've posted is intermediate code to get your XML from a plain old memory buffer (I hope it's Unicode and not chars) into an IXmlReader, but using memory stream.
how do I get an byte[] from HGLOBAL?
I hope you now realise this is an irrelvant question. You only used GlobalAlloc because that's what CreateStreamOnHGlobal required. And you used CreateStreamOnHGlobal because the IXmlReader is initialised from an IStream. Once that's done, it's done.
To reiterate, you need to populate an IXmlWriter and use that to write into another IStream.
XMLLite may be lite by Microsoft Standards, but it seems to be hampered by that COM interface and someone's idea of a clever abstraction. There's a lot to be said for something really simple like TinyXML.