Re: [xml] XPath question

On Wed, Aug 04, 2004 at 11:45:29AM -0400, Jesse Pelton wrote:
So how do you solve the original problem?  That is, how do you construct
an expression to select elements in a particular default namespace? 
     <a xmlns="some-ns">
     <b xmlns="another-ns">
        get the second "n" node.
        define prefix X => another-ns
        if you happen to be in a xsl stylesheet something like
        <xsl:template xmlns:X="another-ns" ...

        The xpath is:

The prefix in the xpath does not have to be the same as the prefix in
the document.

otoh, if you had instead: (note that there is NO xmlns= declaration)
<Y:b xmlns:Y="another-ns">
        you'd need: //X:b/*[local-name()='n']
because then the element 'n' is not in any namespace.  (which is completely
different from the default namespace)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]