mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 21:35:10 +00:00
[MOD] Get rid of childrenless tags in XMLd text
This commit is contained in:
parent
3c5b9aac82
commit
74f3fbdccc
3 changed files with 51 additions and 0 deletions
|
|
@ -162,3 +162,40 @@ XMLookForTKV(XMLElement *parent, char *tag, char *k, char *v)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
XMLElement *
|
||||
XMLCopy(XMLElement *original)
|
||||
{
|
||||
XMLElement *ret = NULL;
|
||||
if (!original)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = Malloc(sizeof(*ret));
|
||||
ret->type = original->type;
|
||||
|
||||
ret->name = StrDuplicate(original->name);
|
||||
ret->data = StrDuplicate(original->data);
|
||||
|
||||
if (original->children)
|
||||
{
|
||||
size_t i;
|
||||
ret->children = ArrayCreate();
|
||||
|
||||
for (i = 0; i < ArraySize(ret->children); i++)
|
||||
{
|
||||
ArrayAdd(ret->children, XMLCopy(ArrayGet(original->children, i)));
|
||||
}
|
||||
}
|
||||
if (original->attrs)
|
||||
{
|
||||
char *name, *value;
|
||||
ret->attrs = HashMapCreate();
|
||||
while (HashMapIterate(original->attrs, &name, (void **) &value))
|
||||
{
|
||||
HashMapSet(ret->attrs, name, StrDuplicate(value));
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue