Lists Home |
Date Index |
> The code works fine as long as I specify the namespace at every level
> eg i2:Environment/i2:Defaults
> What I would like to do is set i2 as a default namespace so I can
> minimise the amount of typing for retrieval.
> eg Environment/Defaults
> I have tried not specifying a prefix in the SelectionNamespaces
> property, however this does not work, I just get an XPath error
As I explained, in XPath an element name without a prefix is *always*
interpreted as refering to an element that belongs to no namespace.
You can't declare a default namespace for the interpretation of
element names in XPath 1.0.
However, this *is* something that is included in XPath 2.0. So give it
another year or so (for XPath 2.0 to reach Recommendation and be
implemented by Microsoft) and you'll be able to do what you want to
do. In the meantime, declare a single-letter prefix and use that
everywhere -- it's only two characters on each element name and it
does make it clearer what kinds of elements your referring to.
Or of course you could stop using namespaces in your XML document, but
I wouldn't really recommend that.