This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Microsoft XML > August 2004 > workaround for xpath 2.0 exists() function?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author workaround for xpath 2.0 exists() function?
rvj

2004-08-24, 7:15 am


Having finally discovered that exists() is a xpath 2.0 function is there a
work around?

For example, I want an expression that will select <aaa> elements that do
not have children containing <aaa> tags

<aaa>
<aaa>
<aaa/>
</aaa>
<aaa> // this node wanted
<bbb/>
</aaa>
<aaa> // this node wanted
<ccc/>
</aaa>
</aaa>

I think the following should work

//aaa[exists(child::*) = true() and exists(child::aaa)=false()]

Can this be done in xpath 1.0?

NB. I tried using count() but count returns zero whether or not a child node
exists







Han

2004-08-24, 7:15 am

Maybe,

aaa[* and not(aaa)]

"rvj" <md@rolemodels.net> wrote in message
news:#RMtBEbiEHA.2992@TK2MSFTNGP12.phx.gbl...
>
> Having finally discovered that exists() is a xpath 2.0 function is there a
> work around?
>
> For example, I want an expression that will select <aaa> elements that do
> not have children containing <aaa> tags
>
> <aaa>
> <aaa>
> <aaa/>
> </aaa>
> <aaa> // this node wanted
> <bbb/>
> </aaa>
> <aaa> // this node wanted
> <ccc/>
> </aaa>
> </aaa>
>
> I think the following should work
>
> //aaa[exists(child::*) = true() and exists(child::aaa)=false()]
>
> Can this be done in xpath 1.0?
>
> NB. I tried using count() but count returns zero whether or not a child

node
> exists
>
>
>
>
>
>
>



rvj

2004-08-25, 11:26 pm

thanks !!

"Han" <hp4444@kornet.net.korea> wrote in message
news:O6Ww4NciEHA.348@tk2msftngp13.phx.gbl...
> Maybe,
>
> aaa[* and not(aaa)]
>
> "rvj" <md@rolemodels.net> wrote in message
> news:#RMtBEbiEHA.2992@TK2MSFTNGP12.phx.gbl...
a[color=darkred]
do[color=darkred]
> node
>
>



Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews