xmlelement.c 966 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*====================================================================*
  2. *
  3. * struct node * xmlelement (struct node const * node, char const * name);
  4. *
  5. * node.h
  6. *
  7. * search node for the named element node; return the node address;
  8. *
  9. * Motley Tools by Charles Maier;
  10. * Copyright (c) 2001-2006 by Charles Maier Associates;
  11. * Licensed under the Internet Software Consortium License;
  12. *
  13. *--------------------------------------------------------------------*/
  14. #ifndef XMLELEMENT_SOURCE
  15. #define XMLELEMENT_SOURCE
  16. #include <string.h>
  17. #include "../nodes/node.h"
  18. struct node const * xmlelement (struct node const * node, char const * name)
  19. {
  20. if (node)
  21. {
  22. node = node->below;
  23. }
  24. while (node)
  25. {
  26. if (node->type == NODE_ELEM)
  27. {
  28. struct node const * temp;
  29. if (!strcmp (node->text, name))
  30. {
  31. break;
  32. }
  33. temp = xmlelement (node, name);
  34. if (temp)
  35. {
  36. return (temp);
  37. }
  38. }
  39. node=node->after;
  40. }
  41. return (node);
  42. }
  43. #endif