I have the xml file as:
<Config>
<tlvid id="2">
<type>10</type>
<Devid>001b00100000</Devid>
</tlvid>
<tlvid id="3">
<sessionid>abcd123</sessionid>
</tlvid>
The code which parses the xml file is:
xmlNode *cur_node = NULL,*sub_node = NULL;
xmlChar *key;
cur_node = a_node->xmlChildrenNode;
while(cur_node !=NULL) {
if((!xmlStrcmp(cur_node->name,(const xmlChar*)"tlvid"))) {
key = xmlGetProp(cur_node,(const xmlChar*)"id");
printf("key: %s\n ",key);
xmlFree(key);
sub_node = cur_node->xmlChildrenNode;
while(sub_node !=NULL) {
key = xmlNodeGetContent(sub_node);
printf("subkey: %s\n ",key);
xmlFree(key);
sub_node = sub_node->next;
}
}
cur_node = cur_node->next;
}
The output as:
key: 2
subkey:
subkey: 10
subkey:
subkey: 001b00100000
subkey:
key: 3
subkey:
subkey: abcd123
subkey:
I have tried xmlKeepBlanksDefault(0); adding under while loop to avoid blanks,but did not help. Can you please help me in removing these empty blanks. Thanks.