Re: [xslt] Set xmlDoc encoding type



I found a way to save to buffer with encoding:

xmlDocPtr xmlDoc = xmlNewDoc(BAD_CAST("1.0"));
// xmlDocSetRootElement(xmlDoc, (xmlNodePtr)node);

xmlBufferPtr buffer = xmlBufferCreate();
xmlCharEncodingHandlerPtr encodingHandler = xmlFindCharEncodingHandler("UTF-8");
xmlOutputBufferPtr buf = xmlOutputBufferCreateBuffer(buffer, encodingHandler);
int ret = xmlSaveFormatFileTo(buf, xmlDoc, "UTF-8", 0);
// xmlBufferContent(buffer);
// xmlBufferLength(buffer);
xmlBufferFree(buffer);
xmlFreeDoc(xmlDoc);

I'm using Windows OS, Is this the best way to save to buffer with encoding?



On Fri, Jun 7, 2013 at 4:42 PM, Alexwell Sandro <alexwellll gmail com> wrote:
Hi, how to set xmlDocPtr encoding type?

I tried this:

xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
doc->encoding = BAD_CAST "UTF-8";

When I call: "xmlFreeDoc(doc);" Error occurs.


Thanks,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]