mirror of
https://github.com/zoriya/xmlParser.git
synced 2026-06-12 05:41:43 +00:00
Adding utilities to count childs
This commit is contained in:
@@ -35,4 +35,5 @@ int xml_getbinaprop(node *n, const char *key);
|
|||||||
int xml_gethexaprop(node *n, const char *key);
|
int xml_gethexaprop(node *n, const char *key);
|
||||||
float xml_getfloatprop(node *n, const char *key);
|
float xml_getfloatprop(node *n, const char *key);
|
||||||
int xml_getchildcount(node *n);
|
int xml_getchildcount(node *n);
|
||||||
|
int xml_getchildcount_filtered(node *n, char *name);
|
||||||
void xml_destroy(node *n);
|
void xml_destroy(node *n);
|
||||||
+16
@@ -6,6 +6,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "xml.h"
|
#include "xml.h"
|
||||||
|
#include "my.h"
|
||||||
|
|
||||||
|
int xml_getchildcount_filtered(node *n, char *name)
|
||||||
|
{
|
||||||
|
int i = 1;
|
||||||
|
|
||||||
|
if (!n || !n->child)
|
||||||
|
return (0);
|
||||||
|
n = n->child;
|
||||||
|
while (n->next) {
|
||||||
|
n = n->next;
|
||||||
|
if (!my_strcmp(n->name, name))
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (i);
|
||||||
|
}
|
||||||
|
|
||||||
int xml_getchildcount(node *n)
|
int xml_getchildcount(node *n)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ char *xml_getproperty(node *n, const char *key)
|
|||||||
{
|
{
|
||||||
for (dictionary *prop = n->properties; prop; prop = prop->next) {
|
for (dictionary *prop = n->properties; prop; prop = prop->next) {
|
||||||
if (!my_strcmp(key, prop->key))
|
if (!my_strcmp(key, prop->key))
|
||||||
return (prop->value);
|
return (my_strdup(prop->value));
|
||||||
}
|
}
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user