Stefan Kost wrote:
> and invoked
> # testXPath -i share/gitk/gitkHelloUser_main.xml
> "//control[ id="UserName"]"
> Object is a Node Set :
> Set contains 0 nodes
Di you try testXPath -i share/gitk/gitkHelloUser_main.xml
"//control[ id='UserName']"
>
> Finaly about "xmlXPathNewContext()", when I had been using a namespace
> with a
> prefix I was using
> ctxt->namespaces=g_new(xmlNsPtr,1);
> ctxt->namespaces[0]=mynamespace;
> ctxt->nsNr=1;
> before using the context. Now that namespace has a "ns->prefix==NULL",
> should I
> still attach it or better use
> ctxt->namespaces=NULL;
> ctxt->nsNr=0;
> It seems to make no difference. I don't use "xmlXPathRegisterNs()" as
> there is
> no version of it accepting a xmlNsPtr.
Stephan,
I'm using the XPath support of libxml in lots of programs and never
had any problem. Since XPath has no notion of a default namespace, you
*MUST* bind every namespace used in your queries to a prefix, even if
you are using a default namespace declaration in the instance. Of course
this prefix can be different from the one used in your document. If you
follow these simple rules you'd be OK. I'm always using
xmlXPathRegisterNs() to add my namespace binding into the XPath engine,
and use these prefix in my expressions. Works like a charm.
--
Fabrice Desré
France Télécom R&D/DTL/TAL
Tél: +(33) (0)2 96 05 31 43
Fax: +(33) (0)2 96 05 39 45
http://www.francetelecom.com/rd