| 125 g_return_if_fail(attr != NULL); |
125 g_return_if_fail(attr != NULL); |
| 126 |
126 |
| 127 for(attr_node = node->child; attr_node; attr_node = attr_node->next) |
127 for(attr_node = node->child; attr_node; attr_node = attr_node->next) |
| 128 { |
128 { |
| 129 if(attr_node->type == XMLNODE_TYPE_ATTRIB && |
129 if(attr_node->type == XMLNODE_TYPE_ATTRIB && |
| 130 !strcmp(attr_node->name, attr)) { |
130 !strcmp(attr_node->name, attr)) |
| |
131 { |
| 131 if(node->child == attr_node) { |
132 if(node->child == attr_node) { |
| 132 node->child = attr_node->next; |
133 node->child = attr_node->next; |
| 133 } else if (node->lastchild == attr_node) { |
|
| 134 node->lastchild = sibling; |
|
| 135 } else { |
134 } else { |
| 136 sibling->next = attr_node->next; |
135 sibling->next = attr_node->next; |
| |
136 } |
| |
137 if (node->lastchild == attr_node) { |
| |
138 node->lastchild = sibling; |
| 137 } |
139 } |
| 138 xmlnode_free(attr_node); |
140 xmlnode_free(attr_node); |
| 139 return; |
141 return; |
| 140 } |
142 } |
| 141 sibling = attr_node; |
143 sibling = attr_node; |
| 153 |
155 |
| 154 for(attr_node = node->child; attr_node; attr_node = attr_node->next) |
156 for(attr_node = node->child; attr_node; attr_node = attr_node->next) |
| 155 { |
157 { |
| 156 if(attr_node->type == XMLNODE_TYPE_ATTRIB && |
158 if(attr_node->type == XMLNODE_TYPE_ATTRIB && |
| 157 !strcmp(attr_node->name, attr) && |
159 !strcmp(attr_node->name, attr) && |
| 158 !strcmp(attr_node->xmlns, xmlns)) { |
160 !strcmp(attr_node->xmlns, xmlns)) |
| |
161 { |
| 159 if(node->child == attr_node) { |
162 if(node->child == attr_node) { |
| 160 node->child = attr_node->next; |
163 node->child = attr_node->next; |
| 161 } else if (node->lastchild == attr_node) { |
|
| 162 node->lastchild = sibling; |
|
| 163 } else { |
164 } else { |
| 164 sibling->next = attr_node->next; |
165 sibling->next = attr_node->next; |
| 165 } |
166 } |
| |
167 if (node->lastchild == attr_node) { |
| |
168 node->lastchild = sibling; |
| |
169 } |
| 166 xmlnode_free(attr_node); |
170 xmlnode_free(attr_node); |
| 167 return; |
171 return; |
| 168 } |
172 } |
| 169 sibling = attr_node; |
173 sibling = attr_node; |
| 170 } |
174 } |
| 202 attrib_node = new_node(attr, XMLNODE_TYPE_ATTRIB); |
206 attrib_node = new_node(attr, XMLNODE_TYPE_ATTRIB); |
| 203 |
207 |
| 204 attrib_node->data = g_strdup(value); |
208 attrib_node->data = g_strdup(value); |
| 205 attrib_node->xmlns = g_strdup(xmlns); |
209 attrib_node->xmlns = g_strdup(xmlns); |
| 206 |
210 |
| 207 xmlnode_insert_child(node, attrib_node); |
211 xmlnode_insert_child(node, attrib_node); |
| 208 } |
212 } |
| 209 |
213 |
| 210 const char * |
214 const char * |
| 211 xmlnode_get_attrib(xmlnode *node, const char *attr) |
215 xmlnode_get_attrib(xmlnode *node, const char *attr) |
| 212 { |
216 { |
| 229 xmlnode *x; |
233 xmlnode *x; |
| 230 |
234 |
| 231 g_return_val_if_fail(node != NULL, NULL); |
235 g_return_val_if_fail(node != NULL, NULL); |
| 232 |
236 |
| 233 for(x = node->child; x; x = x->next) { |
237 for(x = node->child; x; x = x->next) { |
| 234 if(x->type == XMLNODE_TYPE_ATTRIB && |
238 if(x->type == XMLNODE_TYPE_ATTRIB && |
| 235 !strcmp(attr, x->name) && !strcmp(x->xmlns, xmlns)) { |
239 !strcmp(attr, x->name) && !strcmp(x->xmlns, xmlns)) { |
| 236 return x->data; |
240 return x->data; |
| 237 } |
241 } |
| 238 } |
242 } |
| 239 |
243 |
| 240 return NULL; |
244 return NULL; |
| 241 } |
245 } |
| 242 |
246 |
| 243 |
247 |
| 244 void xmlnode_set_namespace(xmlnode *node, const char *xmlns) |
248 void xmlnode_set_namespace(xmlnode *node, const char *xmlns) |
| 245 { |
249 { |