On Mon, Mar 29, 2010 at 3:39 AM, Meghna Singh (External - HCL
TECHNOLOGIES LIMITED) <[email protected]> wrote:
> Hi,
> First of all thanks for your help and response.
> Kindly find the attached code.
> We are using libxml2-2.6.26-2.1.2.
> Trx.tar contain the code
> Src folder will contain all the contain.
> bin folder will contain exe files
> generateexe.sh can be used to generate executable file.
> You need ebb to be installed on machine  :-
> ebb-2.7.5-0
> To convert any text file to exe
> ./trx_convert.exe  INFILE='<txt file>' OUTFILE='<XMl file>'
> XML is attached in file.
> But when this XML file is parsed by using "mbstowcs"  error is coming it 
> returns -1

I don't have windows, so I can't really try out this code, but this
might be part of your problem:

      xmlDocDumpMemory(document,&pszXmlDocument,&iSize);
      *pwszXmlDocument = (wchar_t*)calloc(strlen((const
char*)pszXmlDocument) + 1,sizeof(wchar_t));
      printf("\nPRINTING ALL CHARACTERS FROM THE FILE");
      for(i=0;i<iSize;i++)
      printf(">>%c<<\t",pszXmlDocument[i]);
      printf("\nPRINTED ALL CHARACTERS FROM THE FILE");

      if(mbstowcs(*pwszXmlDocument,(const
char*)pszXmlDocument,strlen((const char*)pszXmlDocument)) ==
(size_t)-1)
      {
         printf("FATAL ERROR  : Could not allocate memory to result
xml buffer!\n");
         iRet = -199;
      }

It looks like you're calloc'ing a new buffer after calling
xmlDocDumpMemory() and before you call mbstowcs().  Then you pass the
new (and presumably blank) buffer to mbstowc().  I don't think that is
what you want.  xmlDocDumpMemory() will allocate memory for you, so
maybe you can just remove the calloc() line.

-- 
Aaron Patterson
http://tenderlovemaking.com/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to