Xpath query exclude ancestors of a particular namespace
The following xpath query gets nodes except where the ancestor is a particular type:
(/def:Image|…|//def:TextBo开发者_开发百科x)[not(ancestor::clpm:EditableText)]
However, I want to be able to exclude all nodes that have an ancestor that is in the clpm
namespace.
Can't work it out guys, any ideas?
Thanks
Use the following as predicate:
not(ancestor::*[starts-with(name(),'clpm:')])
Do note, however, that namespace
and prefix
are quite different things. In a single XML document many different prefixes may be bound to the same namespace and a single prefix may be bound (redefined) to more than one namespace.
In your question you say namespace
, when you mean prefix
.
The XPath expression above is true if the current node doesn't have any ancestors with prefix
clpm.
精彩评论