* htmlNodeDumpFormatOutput: * @buf: the HTML buffer output * @doc: the document * @cur: the current node * @encoding: the encoding string (unused) * @format: should formatting spaces been added * * Dump an HTML node, recursive behaviour,children are printed too. */
| 721 | * Dump an HTML node, recursive behaviour,children are printed too. |
| 722 | */ |
| 723 | void |
| 724 | htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, |
| 725 | xmlNodePtr cur, const char *encoding ATTRIBUTE_UNUSED, |
| 726 | int format) { |
| 727 | xmlNodePtr root, parent; |
| 728 | xmlAttrPtr attr; |
| 729 | const htmlElemDesc * info; |
| 730 | |
| 731 | xmlInitParser(); |
| 732 | |
| 733 | if ((cur == NULL) || (buf == NULL)) { |
| 734 | return; |
| 735 | } |
| 736 | |
| 737 | root = cur; |
| 738 | parent = cur->parent; |
| 739 | while (1) { |
| 740 | switch (cur->type) { |
| 741 | case XML_HTML_DOCUMENT_NODE: |
| 742 | case XML_DOCUMENT_NODE: |
| 743 | if (((xmlDocPtr) cur)->intSubset != NULL) { |
| 744 | htmlDtdDumpOutput(buf, (xmlDocPtr) cur, NULL); |
| 745 | } |
| 746 | if (cur->children != NULL) { |
| 747 | /* Always validate cur->parent when descending. */ |
| 748 | if (cur->parent == parent) { |
| 749 | parent = cur; |
| 750 | cur = cur->children; |
| 751 | continue; |
| 752 | } |
| 753 | } else { |
| 754 | xmlOutputBufferWriteString(buf, "\n"); |
| 755 | } |
| 756 | break; |
| 757 | |
| 758 | case XML_ELEMENT_NODE: |
| 759 | /* |
| 760 | * Some users like lxml are known to pass nodes with a corrupted |
| 761 | * tree structure. Fall back to a recursive call to handle this |
| 762 | * case. |
| 763 | */ |
| 764 | if ((cur->parent != parent) && (cur->children != NULL)) { |
| 765 | htmlNodeDumpFormatOutput(buf, doc, cur, encoding, format); |
| 766 | break; |
| 767 | } |
| 768 | |
| 769 | /* |
| 770 | * Get specific HTML info for that node. |
| 771 | */ |
| 772 | if (cur->ns == NULL) |
| 773 | info = htmlTagLookup(cur->name); |
| 774 | else |
| 775 | info = NULL; |
| 776 | |
| 777 | xmlOutputBufferWriteString(buf, "<"); |
| 778 | if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) { |
| 779 | xmlOutputBufferWriteString(buf, (const char *)cur->ns->prefix); |
| 780 | xmlOutputBufferWriteString(buf, ":"); |
no test coverage detected