Allora, sono alle prime armi con il C++, ho creato una funzione da esportare in Visual Basic:

codice:
#include <string>
#include <windows.h>
#include <COMDEF.H>

BSTR __stdcall ParseXML(LPCSTR pszItem, LPCSTR pszXml, int nCount)
{
	using namespace std;

	int nStart, nEnd = 0;
	string sXml ( (string)pszXml );
	basic_string <char> sTemp;
	string sOpenTag, sCloseTag;

	sOpenTag = "<" + (string)pszItem + ">";
	sCloseTag = "</" + (string)pszItem + ">";

	do
	{
		nStart = sXml.find(sOpenTag, nEnd);
		if ( nStart != -1  )
		{
			nStart += strlen(pszItem) + 2;
			nEnd = sXml.find(sCloseTag, nStart);
			if ( nEnd != -1 )
			{
				sTemp += sXml.substr(nStart, nEnd - nStart);
				sTemp += char("\0");
			}
		}
		if ( nCount == -1 ) break;
	} while ( nStart != -1 );

	if ( sTemp.length() > 0 ) sTemp = sTemp.substr(0, sTemp.length() - 1);

	_bstr_t outValue(sTemp.c_str());
	outValue = SysAllocStringByteLen(outValue, strlen(outValue)) ;
	return outValue.copy();
}
La funzione estrae il contenuto di un tag XML, tag e Xml sono passati in input alla funzione, insieme ad un valore nCount che per ora -1 vale solo il primo tag, 1 per estrarre tutti i tag di quel tipo restituendoli separati da un carattere null.

Se ho una stringa Xml di questo tipo:
<ERRORE>tets test test</ERRORE><ERRORE>test test test test</ERRORE>

la funzione esporta correttamente in Visual Basic:
tets test testtest test test test //con ParseXML("ERRORE", sXml, 1)
tets test test //con ParseXML("ERRORE", sXml)

I problemi sorgono quando il primo tag contiene un numero pari di parole, la stringa restituita termina con un null.

Xml:
<ERRORE>tets test test test</ERRORE>
Risultato della chiamata ParseXML("ERRORE", sXml)
tets test test test // con il carattere null che non si vede ma sta

Questo succede solo con un numero pari di parole.

Qualcuno sa il xchè di questa situazione anomala per me?

Grazie a tutti.

P.S.
Sono disperato