I have this function to convert html in put to xhtml:
char* cleanhtml(char* localhtml)
{
char *buffer_;
static char *cleansed_buffer;
// uses Libtidy to convert the buffer to XML
TidyBuffer output = {0};
TidyBuffer errbuf = {0};
int rc = -1;
bool ok;
TidyDoc tdoc;
tdoc = tidyCreate(); // Initialize "document"
ok = tidyOptSetBool( tdoc, TidyXhtmlOut, yes ); // Convert to XHTML
rc = tidySetErrorBuffer( tdoc, &errbuf ); // Capture diagnostics
rc = tidyParseString(tdoc, localhtml); // Parse the input
rc = tidyCleanAndRepair( tdoc ); // Tidy it up!
rc = tidyRunDiagnostics( tdoc ); // Kvetch// If error, force output.
rc = ( tidyOptSetBool(tdoc, TidyForceOutput, yes) ? rc : -1 );
rc = tidySaveBuffer( tdoc, &output ); // Pretty Print
cleansed_buffer = (char*) malloc(output.size + 1);
memcpy (cleansed_buffer, (char*)output.bp,output.size);
tidyBufFree( &output );
tidyBufFree( &errbuf );
tidyRelease( tdoc );
return cleansed_buffer;
}
But the problem is it is not working correctly...for some reason the xhtml being given out is not being able to be parsed and it is wrong format. So how can libtidy be used to convert a given string(huge string) to xhtml in right format.
And can somebody please give me link to the latest libtidy (dlls,includes) for C.I can't find it anywhere...not even on there website..