xmlselect.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*====================================================================*
  2. *
  3. * char const * xmlselect (struct node const * node, char const * element, char const * attribute);
  4. *
  5. * node.h
  6. *
  7. * search node for the named element and attribute and return the
  8. * attribute value;
  9. *
  10. * if the attribute argument is null or nil then return the element
  11. * content string;
  12. *
  13. * if the element does not exist or the attribute does not exist
  14. * for that element or the attribute has no value then an empty
  15. * string is returned;
  16. *
  17. * Motley Tools by Charles Maier;
  18. * Copyright (c) 2001-2006 by Charles Maier Associates;
  19. * Licensed under the Internet Software Consortium License;
  20. *
  21. *--------------------------------------------------------------------*/
  22. #ifndef XMLSELECT_SOURCE
  23. #define XMLSELECT_SOURCE
  24. #include <string.h>
  25. #include "../nodes/node.h"
  26. char const * xmlselect (struct node const * node, char const * element, char const * attribute)
  27. {
  28. node = xmlelement (node, element);
  29. if ((attribute) && (* attribute))
  30. {
  31. node = xmlattribute (node, attribute);
  32. node = xmlvalue (node);
  33. }
  34. else
  35. {
  36. node = xmldata (node);
  37. }
  38. return (node? node->text: "");
  39. }
  40. #endif