memberlist.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*****************************************************************
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the license contained in the
  4. * COPYING file that comes with the expat distribution.
  5. *
  6. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  7. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  8. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  9. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  10. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  11. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  12. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  13. *
  14. * Must be used with Expat compiled for UTF-8 output.
  15. */
  16. #include <iomanip>
  17. #include <iostream>
  18. #include <list>
  19. #include <map>
  20. #include <sstream>
  21. #include <string>
  22. #include <math.h>
  23. #include <string.h>
  24. #include <stdio.h>
  25. #include <time.h>
  26. #include "../expat_justparse_interface.h"
  27. using namespace std;
  28. void start(const char *el, const char **attr)
  29. {
  30. if (!strcmp(el, "member"))
  31. {
  32. unsigned int ref(0);
  33. string type, role;
  34. for (unsigned int i(0); attr[i]; i += 2)
  35. {
  36. if (!strcmp(attr[i], "ref"))
  37. ref = atol(attr[i+1]);
  38. else if (!strcmp(attr[i], "type"))
  39. type = attr[i+1];
  40. else if (!strcmp(attr[i], "role"))
  41. role = attr[i+1];
  42. }
  43. if (type == "relation")
  44. {
  45. cout<<ref<<'\n';
  46. }
  47. }
  48. }
  49. void end(const char *el)
  50. {
  51. }
  52. int main(int argc, char *argv[])
  53. {
  54. //reading the main document
  55. parse(stdin, start, end);
  56. return 0;
  57. }