summaryrefslogtreecommitdiff
path: root/xml-parser.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2008-12-26 22:58:15 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2008-12-26 22:58:15 +0100
commitc261763c76fb15c1509ee6b88035b604222edc21 (patch)
tree036bccebd81d7a17f99d1a554eec6f11ed8e0ff7 /xml-parser.c
parent82435e6c67c4837b4d5256d8f606b495fffbcc4b (diff)
downloadcataract-c261763c76fb15c1509ee6b88035b604222edc21.tar.xz
Add support for album and index separators
Diffstat (limited to 'xml-parser.c')
-rw-r--r--xml-parser.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/xml-parser.c b/xml-parser.c
index 2b3005a..eb6c86f 100644
--- a/xml-parser.c
+++ b/xml-parser.c
@@ -79,6 +79,37 @@ xml_parser_close (TXMLFile *file)
}
}
+/*
+ * xml_file_get_node_name: retrieve name of the XPath node
+ */
+char *
+xml_file_get_node_name (TXMLFile *file, const char *x_path)
+{
+ xmlXPathObjectPtr xpathObj;
+ xmlNodePtr cur;
+ char *attrv;
+
+ if ((! file) || (! x_path))
+ return NULL;
+
+ /* Evaluate xpath expression */
+ xpathObj = xmlXPathEvalExpression ((const xmlChar *) x_path, file->xpathCtx);
+ if (xpathObj == NULL) {
+ fprintf (stderr, "Error: unable to evaluate xpath expression \"%s\"\n", x_path);
+ return NULL;
+ }
+
+ attrv = NULL;
+ if ((xpathObj->nodesetval) && (xpathObj->nodesetval->nodeNr > 0)) {
+ cur = xpathObj->nodesetval->nodeTab[0];
+ if (cur->name)
+ attrv = strdup ((const char *) cur->name);
+ }
+
+ xmlXPathFreeObject (xpathObj);
+ return attrv;
+}
+
/*
* xml_file_get_node_value: retrieve string value from XPath node