[NTG-context] filtering xml

Hans Hagen pragma at wxs.nl
Mon Feb 21 23:37:55 CET 2011


On 21-2-2011 8:11, Thomas Schmitz wrote:
> Hi all,
>
> this must be easy, but I don't find the solution. Given an xml structure
> like this:
>
> <X>
> <A>dog</A>
> <A><B>cat</B></A>
> <A><B>mouse</B></A>
> </X>
>
> which \xmlfilter expression do I need to get the first <A> element which
> has a subelement <B>? I.e., the filter should only return "cat," not
> "dog" or "mouse." There can be 0 or more elements without <B> before and
> after the one I want to retrieve.
>
> Sorry if this is elementary, but I looked at xml-mkiv.pdf and mk.pdf and
> couldn't find an answer.

"A/B[1]"

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list