Hi Martin,
 
 Thanks for the quick response.  Its all starting to make sense now.
 
Best Regards
 Alistair Leslie-Hughes



> Date: Fri, 18 Apr 2008 12:32:34 +0100> From: [EMAIL PROTECTED]> To: [EMAIL 
> PROTECTED]> Subject: Re: [xml] Namespace Query Issue> CC: [email protected]> > On 
> 18/04/2008, Alistair Leslie-Hughes <[EMAIL PROTECTED]> wrote:> > Hi,> >> > 
> When use xmlXPathEval with the query "/root/WEB:Site" on the following xml> 
> >> > <?xml version=\"1.0\"?>> > <root xmlns:WEB='http://www.winehq.org'>> > 
> <WEB:Site version=\"1.0\" />> > </root>> >> > I get the following error> > 
> XPath error : Undefined namespace prefix> > xmlXPathEval: evaluation failed> 
> >> > Using the same xml and query in MSXML it works.> >> > Can someone 
> explain what I am doing wrong?> >> > Best Regards> > Alistair Leslie-Hughes> 
> > You need to register the namespace prefix/uri pair on the xpath context.> > 
> See:> http://xmlsoft.org/html/libxml-xpathInternals.html#xmlXPathRegisterNs> 
> > Some example xpath code:> http://xmlsoft.org/examples/xpath1.c> > Or python 
> version, which is brief enough for email:> >>> import libxml2> >>> doc = 
> libxml2.parseDoc("""<?xml version="1.0"?>> ... <root 
> xmlns:WEB='http://www.winehq.org'>> ... <WEB:Site version="1.0"/>> ... 
> </root>""")> >>> ctx = doc.xpathNewContext()> >>> ctx.xpathRegisterNs("WEB", 
> "http://www.winehq.org";)> 0> >>> ctx.xpathEval("count(//WEB:*)")> 1.0> > This 
> one really needs to go on an FAQ thingy really.> > Martin
_________________________________________________________________
It's simple! Sell your car for just $30 at CarPoint.com.au
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to