tags:

views:

915

answers:

3

I know this is a simple question, but I can't figure it out. Consider the following simple XML document:

<root>
  <a></a>
  <b></b>
  <c></c>
  <a></a>
  <d></d>
  <e></e>
  <a></a>
  <a></a>
</root>

What's the best way to select the nodes <b> through <e> using XPath?

I'm looking for something like "/root/*[not(a)]" (which does not do the trick)

A: 

Have you tried:

/root/b|/root/c|root/d|/root/e

chinna
That's how I had it implemented. Unfortunately, there might be other nodes with unknown names
Pumbaa80
+10  A: 
/root/*[not(self::a)]
Tomalak
This also works when using XPointer and XInclude.
scompt.com
+1  A: 

I realize this is an old question, but I recently ran into a similar problem and used the following xpath to solve it:

/root/*[not(name()='a')]
BVH