XML parsing aide
XMLaide.cpp
- Committer:
- takashikojo
- Date:
- 2015-07-05
- Revision:
- 2:c86701a4f5b0
- Parent:
- 1:ad5fd8c29c1f
File content as of revision 2:c86701a4f5b0:
#include <mbed.h> #include "XMLaide.h" #include <algorithm> const char *XML_getTag(const char *p, const char *name) { const char *find ; #define TAG_SIZE 20 char tag[TAG_SIZE] = "<" ; if(p == NULL)return NULL ; find = strstr(p, strcat(tag, name)) ; if(find) { find = strchr(find, '>') ; return find + 1 ; } else return NULL ; } const char *XML_getElement(const char *p, char *element, int size) { const char *find ; if(p == NULL)return NULL ; find = strstr(p, "</") ; if(find) { strncpy(element, p, min((find-p), size)) ; element[min((find-p), size)] = '\0' ; } else *element = '\0' ; return find ; }