* xmlNodeDumpOutput: * @buf: the XML buffer output * @doc: the document * @cur: the current node * @level: the imbrication level for indenting * @format: is formatting allowed * @encoding: an optional encoding string * * Dump an XML node, recursive behaviour, children are printed too. * Note that @format = 1 provide node indenting only if xmlIndentTreeOutput = 1 * or xmlKeepBlanksDef
| 2570 | * or xmlKeepBlanksDefault(0) was called |
| 2571 | */ |
| 2572 | void |
| 2573 | xmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, |
| 2574 | int level, int format, const char *encoding) |
| 2575 | { |
| 2576 | xmlSaveCtxt ctxt; |
| 2577 | #ifdef LIBXML_HTML_ENABLED |
| 2578 | xmlDtdPtr dtd; |
| 2579 | int is_xhtml = 0; |
| 2580 | #endif |
| 2581 | |
| 2582 | (void) doc; |
| 2583 | |
| 2584 | xmlInitParser(); |
| 2585 | |
| 2586 | if ((buf == NULL) || (cur == NULL)) return; |
| 2587 | |
| 2588 | if (level < 0) |
| 2589 | level = 0; |
| 2590 | else if (level > 100) |
| 2591 | level = 100; |
| 2592 | |
| 2593 | if (encoding == NULL) |
| 2594 | encoding = "UTF-8"; |
| 2595 | |
| 2596 | memset(&ctxt, 0, sizeof(ctxt)); |
| 2597 | ctxt.buf = buf; |
| 2598 | ctxt.level = level; |
| 2599 | ctxt.format = format ? 1 : 0; |
| 2600 | ctxt.encoding = (const xmlChar *) encoding; |
| 2601 | xmlSaveCtxtInit(&ctxt); |
| 2602 | ctxt.options |= XML_SAVE_AS_XML; |
| 2603 | |
| 2604 | #ifdef LIBXML_HTML_ENABLED |
| 2605 | dtd = xmlGetIntSubset(doc); |
| 2606 | if (dtd != NULL) { |
| 2607 | is_xhtml = xmlIsXHTML(dtd->SystemID, dtd->ExternalID); |
| 2608 | if (is_xhtml < 0) |
| 2609 | is_xhtml = 0; |
| 2610 | } |
| 2611 | |
| 2612 | if (is_xhtml) |
| 2613 | xhtmlNodeDumpOutput(&ctxt, cur); |
| 2614 | else |
| 2615 | #endif |
| 2616 | xmlNodeDumpOutputInternal(&ctxt, cur); |
| 2617 | } |
| 2618 | |
| 2619 | /** |
| 2620 | * xmlDocDumpFormatMemoryEnc: |
no test coverage detected