@@ -42,6 +42,7 @@ XMLNodes::XMLNodes(Transaction *transaction)
42
42
node_depth (0 ),
43
43
currpath(" " ),
44
44
currval(" " ),
45
+ currval_is_set(false ),
45
46
m_transaction(transaction)
46
47
{}
47
48
@@ -68,20 +69,21 @@ class MSCSAXHandler {
68
69
// note, the condition should always be true because there is always a pseudo root element: 'xml'
69
70
if (xml_data->nodes .size () > 1 ) {
70
71
xml_data->currpath .append (" ." );
71
- xml_data->nodes [xml_data->nodes .size ()-1 ]->has_child = true ;
72
+ xml_data->nodes [xml_data->nodes .size ()-2 ]->has_child = true ;
72
73
}
73
74
xml_data->currpath .append (name);
74
75
// set the current value empty
75
76
// this is necessary because if there is any text between the tags (new line, etc)
76
77
// it will be added to the current value
77
78
xml_data->currval = " " ;
79
+ xml_data->currval_is_set = false ;
78
80
}
79
81
80
82
void onEndElement (void * ctx, const xmlChar *localname) {
81
83
std::string name = reinterpret_cast <const char *>(localname);
82
84
XMLNodes* xml_data = static_cast <XMLNodes*>(ctx);
83
85
const std::shared_ptr<NodeData>& nd = xml_data->nodes [xml_data->nodes .size ()-1 ];
84
- if (nd->has_child == true ) {
86
+ if (nd->has_child == false ) {
85
87
// check the return value
86
88
// if false, then stop parsing
87
89
// this means the number of arguments reached the limit
@@ -97,6 +99,7 @@ class MSCSAXHandler {
97
99
xml_data->nodes .pop_back ();
98
100
xml_data->node_depth --;
99
101
xml_data->currval = " " ;
102
+ xml_data->currval_is_set = false ;
100
103
}
101
104
102
105
void onCharacters (void *ctx, const xmlChar *ch, int len) {
@@ -106,7 +109,12 @@ class MSCSAXHandler {
106
109
// libxml2 SAX parser will call this function multiple times
107
110
// during the parsing of a single node, if the value has multibyte
108
111
// characters, so we need to concatenate the values
109
- xml_data->currval += content;
112
+ if (xml_data->currval_is_set == false ) {
113
+ xml_data->currval = content;
114
+ xml_data->currval_is_set = true ;
115
+ } else {
116
+ xml_data->currval += content;
117
+ }
110
118
}
111
119
};
112
120
0 commit comments