Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. bool print_xml(Printer *p, XML_Node *node)
  2. {
  3. bool success;
  4.  
  5. success =
  6. print(p, '<') &&
  7. print(p, node->tag);
  8. if (!success) return false;
  9.  
  10. for (U32 i = 0; i < node->attribute_count; i++) {
  11. XML_Attribute attr = node->attributes[i];
  12. success =
  13. print(p, ' ') &&
  14. print(p, attr.key) &&
  15. print(p, "=\"") &&
  16. print(p, attr.value) &&
  17. print(p, '"');
  18. if (!success) return false;
  19. }
  20.  
  21. if (!print(&p, '>')) return false;
  22.  
  23. for (XML_Node *child = node->children; child; child = child->next) {
  24. if (!print_xml(p, node)) return false;
  25. }
  26.  
  27. success =
  28. print(p, "</") &&
  29. print(p, node->tag) &&
  30. print(p, '>');
  31. if (!success) return false;
  32.  
  33. return true;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement