xml.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef MUPDF_FITZ_XML_H
  2. #define MUPDF_FITZ_XML_H
  3. #include "mupdf/fitz/system.h"
  4. #include "mupdf/fitz/context.h"
  5. /*
  6. XML document model
  7. */
  8. typedef struct fz_xml_s fz_xml;
  9. /*
  10. fz_parse_xml: Parse the contents of buffer into a tree of xml nodes.
  11. preserve_white: whether to keep or delete all-whitespace nodes.
  12. */
  13. fz_xml *fz_parse_xml(fz_context *ctx, fz_buffer *buf, int preserve_white);
  14. /*
  15. fz_xml_prev: Return previous sibling of XML node.
  16. */
  17. fz_xml *fz_xml_prev(fz_xml *item);
  18. /*
  19. fz_xml_next: Return next sibling of XML node.
  20. */
  21. fz_xml *fz_xml_next(fz_xml *item);
  22. /*
  23. fz_xml_up: Return parent of XML node.
  24. */
  25. fz_xml *fz_xml_up(fz_xml *item);
  26. /*
  27. fz_xml_down: Return first child of XML node.
  28. */
  29. fz_xml *fz_xml_down(fz_xml *item);
  30. /*
  31. fz_xml_is_tag: Return true if the tag name matches.
  32. */
  33. int fz_xml_is_tag(fz_xml *item, const char *name);
  34. /*
  35. fz_xml_tag: Return tag of XML node. Return NULL for text nodes.
  36. */
  37. char *fz_xml_tag(fz_xml *item);
  38. /*
  39. fz_xml_att: Return the value of an attribute of an XML node.
  40. NULL if the attribute doesn't exist.
  41. */
  42. char *fz_xml_att(fz_xml *item, const char *att);
  43. /*
  44. fz_xml_text: Return the text content of an XML node.
  45. Return NULL if the node is a tag.
  46. */
  47. char *fz_xml_text(fz_xml *item);
  48. /*
  49. fz_drop_xml: Free the XML node and all its children and siblings.
  50. */
  51. void fz_drop_xml(fz_context *doc, fz_xml *item);
  52. /*
  53. fz_detach_xml: Detach a node from the tree, unlinking it from its parent.
  54. */
  55. void fz_detach_xml(fz_xml *node);
  56. /*
  57. fz_debug_xml: Pretty-print an XML tree to stdout.
  58. */
  59. void fz_debug_xml(fz_xml *item, int level);
  60. fz_xml *fz_xml_find(fz_xml *item, const char *tag);
  61. fz_xml *fz_xml_find_next(fz_xml *item, const char *tag);
  62. fz_xml *fz_xml_find_down(fz_xml *item, const char *tag);
  63. #endif