Reputation: 4003
I'm starting with just the xml:id of a given paragraph and I'm trying to get the xml:id of the preceding paragraph. Here's what I have so far. Right now, I'm getting all the xml:id's of the preceding paragraphs. But I only want the immediately preceding paragraph.
//p[following::p[@xml:id='d1l46adaacp']]/@xml:id
Please help.
Upvotes: 2
Views: 170
Reputation: 4003
Here's the answer I discovered after my post.
Basically I was thinking about things backward. I was looking for any p
that had a following p
with the designated xml:id
. I was not able to add [1] to the end because this was giving me any p
that was first in its parent element.
What I have below works better. Now instead of trying to go straight to the preceding paragraph, I start at the paragraph whose xml:id
I know, then I go to the preceding paragraph, stop at the first one [1], and ask for the xml:id.
//p[@xml:id='d1l46adaacp']/preceding::p[1]/@xml:id
Upvotes: 2