Re: [xml] a question about getting the element content with name space
- From: Momena Akter Ahmed <momenaa yahoo com>
- To: veillard redhat com
- Cc: xml gnome org
- Subject: Re: [xml] a question about getting the element content with name space
- Date: Tue, 11 Nov 2003 12:08:28 -0800 (PST)
--- Daniel Veillard <veillard redhat com> wrote:
On Mon, Nov 10, 2003 at 11:35:26PM -0800, Momena
Akter Ahmed wrote:
Here is my xpath :
child::node2='test'
It worked okay. But after I added the namespace
stuff,
how do I compose my xpath query to compare the
content
of the child node ?
child::ns:node2='test'
but you need to have the namespace prefix 'ns'
defined in the
XPath context. In XSLT it's inherited from the node
containing
the XPath expression. Outside XSLT there is no
specification defining
this. The API is
http://xmlsoft.org/html/libxml-xpathInternals.html#xmlXPathRegisterNs
to register a namespace to an XPath evaluation
context.
Daniel
Thanks for the quick response.
My xml looks like this :
<root_node xmlns:pwg="http://www.pwg.org">
<node1>
<pwg:node2>test</pwg:node2>
</node1>
</root_node>
The code I am now using is :
xmlXPathRegisterNs (context, (xmlChar *)"pwg",
(xmlChar *)"http://www.pwg.org");
sprintf (query, "child::pwg:node2='test'");
Still it is not working. Using debugger, I can see
that the ns menber of node2 knows about pwg and my
URI.
Momena
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]