cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

XPATH help

cleccese
5-Regular Member

XPATH help

<
<listitem><para>text
<randomlist>
<I am here<para>text</para></listitem>
<listitem><para>text</para></listitem>
<listitem><para>text</para></listitem>
</randomlist>
</para></listitem>
</randomlist>

I'm trying to test if the top randomList has listItemPrefix="pf01" and ignore it if it doesn't have the attribute set


This doesn't work, I thought it would take me to the first randomList ancestor of listitem parent
../ancestor::randomList[1][@listitemPrefix='pf01']


Thanks for any help!

7 REPLIES 7

Try: ../randomList/@listItemPrefix="pf01"


Trevor Hendricks<">mailto:->
Project Analyst -- Publication Systems
Technical Communications, MS: 078
cleccese
5-Regular Member
(To:cleccese)

Thank you, Trevor, that didn't work.

Hi Caroline,

Maybe ancestor::randomList[last()][@listitemPrefix='pf01']
The ancestors are listed in reverse order, so you want the
last one to get the outer one.

Regards,
Richard

cleccese
5-Regular Member
(To:cleccese)

this works:


../ancestor::randomList[1][@listItemPrefix='pf01']


Wait, what? That's what I had originally, but now it's working for some reason.

cleccese
5-Regular Member
(To:cleccese)

Thanks, Richard, unfortunately didn't work. (There were two randomLists, easy to miss)

How about:

./ancestor::randomlist[@listItemPrefix="pf01" and not(ancestor::randomlist)]

So that would be looking for an ancestor that has the prefix, but also is
not a child of other randomlists?


On Wed, Mar 26, 2014 at 11:43 AM, Hendricks Trevor <
-> wrote:

> Try: ../randomList/@listItemPrefix="pf01"
>
>
>
>
>
> *Trevor Hendricks* <->
> Project Analyst -- Publication Systems
> Technical Communications, MS: 078
>
> *m*: 920-226-2116
> *p*: 920-457-4441; ext. 73571
> *f*: 920-803-3939
> *e*: -
> *Experience gracious living with **Kohler
>
>
>
> Math problems?? Call 1-800-10x(24+13)-(64-8y)/2+36x-17.
>
>
>
>
>
>
>
> *From:* Caroline Leccese [
> <listitem><para>text
> <randomlist>
> <listitem>I am here<para>text</para></listitem>
> <listitem><pa...














cleccese
5-Regular Member
(To:cleccese)

Hi Keith,


Thanks for the reply, unfortunately it didn't work.


This did: ../ancestor::randomList[1][@listItemPrefix='pf01']

Announcements