Re: [xml] LIBXML2 error
- From: Aaron Patterson <aaron patterson gmail com>
- To: "Meghna Singh (External - HCL TECHNOLOGIES LIMITED)" <external meghna singh ikea com>
- Cc: "xml gnome org" <xml gnome org>
- Subject: Re: [xml] LIBXML2 error
- Date: Mon, 29 Mar 2010 08:23:08 -0700
On Mon, Mar 29, 2010 at 3:39 AM, Meghna Singh (External - HCL
TECHNOLOGIES LIMITED) <external meghna singh ikea com> 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/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]