From c261763c76fb15c1509ee6b88035b604222edc21 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Fri, 26 Dec 2008 22:58:15 +0100 Subject: Add support for album and index separators --- xml-parser.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'xml-parser.c') 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 -- cgit v1.2.3