xmlelement.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 <cmaier@cmassoc.net>;
  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