Archived

This topic is now archived and is closed to further replies.

search: VARIANT, XML, C++, IXMLDOMDocument, etc.

This topic is 5504 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Yeah, ok, the forum search engine still doesn''t work (no pressure, btw) so these are the terms I am needing some clarification on...
  
IXMLDOMDocument * pDoc;

//Init COM...



VARIANT filename;
filename.vt = VT_BSTR;
filename.bstrVal = CComBSTR("text.xml");
VARIANT_BOOL * result = false;

HRESULT loadResult = pDoc->load(filename, result);

  
I am really struggling to find wtf is going wrong here.., As load returns E_INVALID_ARG to my efforts. Have also attempted to use CComVariants for filename, but to no success. Currently googling for answers, as MSDN just does not make it clear to me what is wrong with this code, but if anyone has suggestions, please do... Thanks...

Share this post


Link to post
Share on other sites
Maybe this line:

  
VARIANT_BOOL * result = false;

You set result (which is pointer) to false (=NULL).
I think you mean here this:

  
bool b = false;
VARIANT_BOOL * result = &b;

Share this post


Link to post
Share on other sites
You want this:

VARIANT_BOOL result;
HRESULT loadResult = pDoc->load( filename, &result );


BTW, is there any reason why you''re not using ATL (to it''s fullest, you''ve got a CComBSTR in there)? It really makes your life easier when you''re dealing with COM, i.e. you could actually do something like this:

CComPtr pDoc( "The.ProgID" );
try
{
    BOOL bResult = pDoc->load( _T("text.xml") );
}
catch( _com_error err )
{
    DisplayError( err.Description() );
}


And so on...

If I had my way, I''d have all of you shot!


codeka.com - Just click it.

Share this post


Link to post
Share on other sites
First off, thanks above - got rid of the E_INVALIDARG (My problem answered in docs below - which i had read, but didn''t absorb)

But...

OK. MSDN''s kinda ambiguous docs state that:


  
C/C++ Return Values
S_OK
-Value returned if successful.
S_FALSE
-Value returned if the load fails.
E_INVALIDARG
-Value returned if isSuccessful is Null.


Unfortunately, S_FALSE is the answer I am receiving to my request and it doesn''t give any hints to why the failure. I am getting this in the debug window:


  
First-chance exception at 0x77e6d756 in xml experiment.exe: 0xE0000001: 0xe0000001.
First-chance exception at 0x77e6d756 in xml experiment.exe: 0xE0000001: 0xe0000001.
First-chance exception at 0x77e6d756 in xml experiment.exe: 0xE0000001: 0xe0000001.
First-chance exception at 0x77e6d756 in xml experiment.exe: 0xE0000001: 0xe0000001.
First-chance exception at 0x77e6d756 in xml experiment.exe: 0xE0000001: 0xe0000001.


But am unsure of the problem... The paramaters (appear) correct in the debug, the file is there (have checked current dir at runtime) - and valid (will post if disbelief occurs, but pretty sure).

Any help appreciated.., thanks

Share this post


Link to post
Share on other sites