Suppose I have xml like this:
<Products>
<Product name="Liquid Oxygen">
<Manufacturer name="Universal Exports" country="UK" />
</Product>
<Product name="Hydrazine">
<Manufacturer name="ACME Inc." country="USA" />
</Product>
<Product name="Gaseous Oxygen" obsolete="true">
<Manufacturer name="Universal Exports" country="UK" />
</Product>
<Product name="Liquid Nitrogen">
<Manufacturer name="Penguins R Us" country="Antarctica" />
</Product>
</Products>
And I want to pick out the Product nodes that have a Manufacturer
subnode with @country
of UK
, but that do not have an @obsolete
of true
. I can say either
/Products/Product[Manufacturer/@country = 'UK' and not(@obsolete = 'true)]
or
/Products/Product[Manufacturer/@country = 'UK'][not(@obsolete = 'true')]
and both get me the nodes I want.
My question is, is there any functional difference between these two approaches to and-ed conditions? Is there a situation in which the different approaches could give different results? (I realise that and
serves a purpose within more complex conditions) Stylistically, is one to be preferred over the other?
(I'm using C# and .NET 2.0, but I don't believe that will have any bearing on the answer)