Ciao a tutti ho un problema con libxml2 ed un programma in scritto in C.

Devo recuperare alcune informazioni contenute in un codice XML che arriva dall'interrogazione di un dB.

il codice XML è questo:
<gmd:MD_Metadata xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:gts="http://www.isotc211.org/2005/gts" xmlns:gco="http://www.isotc211.org/2005/gco">
<gmd:fileIdentifier>
<gco:CharacterString xmlns:srv="http://www.isotc211.org/2005/srv" xmlns:gmx="http://www.isotc211.org/2005/gmx">8a0bbb8e-6bf0-45d7-9401-0795ed64b1f6</gco:CharacterString>
</gmd:fileIdentifier>

....

ed il codice C è questo:
supponiamo che in results c'è il risultato della query ovvero l'XML
Codice PHP:
int main(int argccharargv[]) {
    ...
    
char *results     // results coming from the PostgreSQL database query
    
const xmlChar *xpathExpr;

    
xmlXPathObjectPtr xpathObj;
    
xmlXPathContextPtr xpathCtx;
    
xmlDocPtr doc;

    ...

xpathExpr = (xmlChar*) "/MD_Metadata/fileIdentifier/CharacterString";

xmlInitParser();

doc xmlParseMemory (resultsstrlen(results));
xpathCtx xmlXPathNewContext(doc);

// Register namespaces
if(register_namespaces(xpathCtxnameSpaces) < 0
       exit(
2)

xpathObj xmlXPathEvalExpression(xpathExprxpathCtx);
if (
xmlXPathNodeSetIsEmpty(xpathObj->nodesetval))
    exit(
3
la funzione register_namespaces serve appunto a registrare i namespaces attraverso la funzione xmlXPathRegisterNs.

Il problema è che la mia applicazione esce con il codice 3, ovvero il risultato della funzione xmlXPathEvalExpression è vuoto.

Qualcuno può aiutarmi a capire cosa sbaglio?
H provato diverse soluzioni (ad esempio a salvare la stringa sul file e a rileggerla con xmlParseFile) ma il risultato è sempre lo stesso

Grazie