[libxml++] default namespace
- From: panoply att net
- To: libxml++ <libxmlplusplus-general lists sourceforge net>
- Subject: [libxml++] default namespace
- Date: Tue, 19 Jul 2005 19:38:20 +0000
The reading I've done tells me that with XML1.1 there is no way to use default namespaces in XPath searches. Ok, so now I'd like to know the work-around. One thing I found in another post was this:
-------------------------------------------------------
What I can do, is register some dummy namespace:
eg:
xmlNodePtr current_node=(get this node some magic way);
xmlNsPtr nsdefptr = current_node->nsDef;
if(nsdefptr != NULL) {
if(nsdefptr->prefix == NULL) {
xmlXPathRegisterNs(xpath_context,
(const xmlChar *)"dummy",
nsdefptr->href);
}
}
but in this case I have to prefix all my XPath query
element id's (which are meant to be in the default namespace)
with dummy: (eg <foo/> needs XPath: /dummy:foo)
------------------------------------------------------------
taken from: http://mail.gnome.org/archives/xml/2003-April/msg00143.html
If I understand the above code correctly, it is assigning a prefix to the default namespace, then using that prefix in XPath searches. Is that correct? I AM PERFECTLY HAPPY resolving my problem this way (if it will work). But I want to find out if this can be done through the libxml++ wrapper - and if this over-all approach is Kosher.
-Brent
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]