View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000136 | easycwmp | Enhancement | public | 2016-05-17 16:31 | 2016-05-26 10:11 |
Reporter | mohamed.kallel | Assigned To | mohamed.kallel | ||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | resolved | Resolution | no change required | ||
Summary | 0000136: use mxmlGetNextSibling() in xml_get_value_with_whitespace() | ||||
Description | According to an EasyCwmp contributor, it's better to use mxmlGetNextSibling() in xml_get_value_with_whitespace() in this way: char *xml_get_value_with_whitespace(mxml_node_t **b) { //b is a TEXT and it is the first child in the ELEMENT //If a string has spaces, it is represented as multiple TEXT siblings. char * value = calloc(1, sizeof(char)); do { value = realloc(value, strlen(value) + strlen((*b)->value.text.string) + 2); /*handle leading space before this string*/ if ((*b)->value.text.whitespace == 1) strcat(value, " "); strcat(value, (*b)->value.text.string); } while ((*b = mxmlGetNextSibling(*b)) && (*b)->type == MXML_TEXT); return value; } attached test.c and test.xml | ||||
Tags | No tags attached. | ||||
|
test.c (1,182 bytes)
#include "stdio.h" #include "stdlib.h" #include "string.h" #include <pthread.h> #include <microxml.h> /* gcc -g -o test test.c -lmicroxml -lpthread */ char *xml_get_value_with_whitespace(mxml_node_t **b) { //b is a TEXT and it is the first child in the ELEMENT //If a string has spaces, it is represented as multiple TEXT siblings. char * value = calloc(1, sizeof(char)); do { value = realloc(value, strlen(value) + strlen((*b)->value.text.string) + 2); /*handle leading space before this string*/ if ((*b)->value.text.whitespace == 1) strcat(value, " "); strcat(value, (*b)->value.text.string); } while ((*b = mxmlGetNextSibling(*b)) && (*b)->type == MXML_TEXT); return value; } void main (void) { FILE* fp; mxml_node_t* b; char *value; fp = fopen("test.xml", "r"); b = mxmlLoadFile(NULL, fp, MXML_TEXT_CALLBACK); fclose(fp); //I want to get the string content b = mxmlFindElement(b, b, "ParameterName", NULL, NULL, MXML_DESCEND); b = mxmlGetFirstChild(b); value = xml_get_value_with_whitespace(&b); printf("value is --%s--\n", value); free(value); } |
|
|
|
this issue is uselss since the use of mxmlGetNextSibling() could cause many cases to take in account. So we keep the current solution for the moment |
Date Modified | Username | Field | Change |
---|---|---|---|
2016-05-17 16:31 | mohamed.kallel | New Issue | |
2016-05-17 16:32 | mohamed.kallel | File Added: test.c | |
2016-05-17 16:32 | mohamed.kallel | File Added: test.xml | |
2016-05-26 10:11 | mohamed.kallel | Note Added: 0000478 | |
2016-05-26 10:11 | mohamed.kallel | Status | new => resolved |
2016-05-26 10:11 | mohamed.kallel | Resolution | open => no change required |
2016-05-26 10:11 | mohamed.kallel | Assigned To | => mohamed.kallel |