extern "C" void DumpXMLString(xmlNodePtr node) { xmlOutputBufferPtr buf = xmlOutputBufferCreateFile(stdout, nullptr); xmlNodeDumpOutput(buf, node->doc, node, 0, 0, nullptr); xmlOutputBufferClose(buf); fprintf(stdout, "\n\n"); }
/** * htmlNodeDumpFileFormat: * @out: the FILE pointer * @doc: the document * @cur: the current node * @encoding: the document encoding * @format: should formatting spaces been added * * Dump an HTML node, recursive behaviour,children are printed too. * * TODO: if encoding == NULL try to save in the doc encoding * * returns: the number of byte written or -1 in case of failure. */ int htmlNodeDumpFileFormat(FILE *out, xmlDocPtr doc, xmlNodePtr cur, const char *encoding, int format) { xmlOutputBufferPtr buf; xmlCharEncodingHandlerPtr handler = NULL; int ret; xmlInitParser(); if (encoding != NULL) { xmlCharEncoding enc; enc = xmlParseCharEncoding(encoding); if (enc != XML_CHAR_ENCODING_UTF8) { handler = xmlFindCharEncodingHandler(encoding); if (handler == NULL) return(-1); } } /* * Fallback to HTML or ASCII when the encoding is unspecified */ if (handler == NULL) handler = xmlFindCharEncodingHandler("HTML"); if (handler == NULL) handler = xmlFindCharEncodingHandler("ascii"); /* * save the content to a temp buffer. */ buf = xmlOutputBufferCreateFile(out, handler); if (buf == NULL) return(0); htmlNodeDumpFormatOutput(buf, doc, cur, encoding, format); ret = xmlOutputBufferClose(buf); return(ret); }
extern "C" void DebugPrintNodeConst(std::shared_ptr<const ePub3::xml::Node> aNode) { auto output = xmlOutputBufferCreateFile(stderr, nullptr); xmlNodeDumpOutput(output, aNode->Document()->xml(), aNode->xml(), 0, 1, "UTF-8"); xmlOutputBufferClose(output); }