views:

356

answers:

1

Where does MSXML IXMLDOMDocument::save save? I mean when it's called with a file name argument.

CComPtr< IXMLDOMDocument > doc;
p->get_doc( &doc );
doc->save( CComVariant( L"C:\\pathto\\mydoc.xml" ) );

Where will "C:\pathto\mydoc.xml" be?

Consider that the XMLDOMDocument is out of process, in this case located on a different physical machine. Will it save it to "C:..." of the calling machine, or the server hosting the COM object?

+1  A: 

It will be at the location you give it on your local system. The save function interprets its argument as a path and file name if you give it a string, so that's the file that the object saves its contents into. The file doesn't need to exist beforehand, but the directories should.

In addition to strings, the save function can also accept certain other types of arguments, including "an ASP Response object, an XML document object, or a custom object that supports persistence." See the documentation for details.

Rob Kennedy
Let's say the code snippet is running on PC1 and doc is pointing to a COM object which is on PC2, what is the "local system"? The one on PC1 or the one on PC2?
uvts_cvs
PC2, I would imagine. What happened when you tried it out?
Rob Kennedy
It happened to be on PC2 as you correctly imagine.
uvts_cvs
Good. Then it's because the *code* is running on PC2. The object on PC1 is just a stub that forwards all its method calls to the remote computer. When the code on PC2 interprets the path, it sees it as a local path. To save the file on PC1, you'd need an object created on PC1, one that implements something like IPersistFile. Give that to the `save` method, and the data will be transferred over the wire.
Rob Kennedy
Looks like we have an answer. "What happened when you tried it out?" "It saved to the local PC". Q.E.D.
Ian Boyd