|
Subject: Re: [xsl] xpath help? From: "David Carlisle d.p.carlisle@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 12 Feb 2025 22:58:13 -0000 |
you are selecting all elements that are the first child of their parent
use
(//a[contains(@filepath, 'preface.html')])[1]/@newid
or
/descendant::a[contains(@filepath, 'preface.html')][1]/@newid
David
On Wed, 12 Feb 2025 at 22:53, dvint@xxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> I have this xpath that returns more than one result
>
> //a[contains(@filepath, 'preface.html')]/@newid
>
> I thought adding [1] to it like this would get me the first entry, but
> the result doesn't change
>
> //a[contains(@filepath, 'preface.html')][1]/@newid
>
> Here is an example of the file I'm processing
>
>
> <nav>
> <div class="coverpage">
> <span class="publicationdate">February 12, 2025</span>
> </div>
> <div class="copyrightstatement"/>
> <div class="toc">
> <ul class="nav-list">
> <li class="nav-item is-current-page"
> data-depth="1">
> <a newid="d3e90" class="nav-link"
> filepath="preface.html"
> href="#d3e90"
> entry-type="file">Evaluation</a>
> </li>
> <li class="nav-item" data-depth="1">
> <a newid="d3e139" class="nav-link"
>
> filepath="${release.notes.base}/preface.html" href="#d3e139"
> entry-type="URL">Release notes</a>
> </li>
> <li class="nav-item" data-depth="1">
> <a newid="d3e237" class="nav-link"
>
> filepath="../deployment-planning-guide/preface.html"
> href="#d3e237"
> entry-type="file">Deployment planning</a>
> </li>
> <li class="nav-item" data-depth="2">
> <a newid="d3e247" class="nav-link"
>
> filepath="../deployment-planning-guide/understanding-iam.html"
> href="#d3e247"
> entry-type="file">Identity and Access
> Management</a>
> </li>
> <li class="nav-item" data-depth="3">
> <a newid="d3e255" class="nav-link"
>
> filepath="../deployment-planning-guide/not-just-sso.html"
> href="#d3e255"
> entry-type="file">More than just single
> sign-on</a>
> </li>
> </ul>
> </div>
> </nav>
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] xpath help?, dvint@xxxxxxxxx | Thread | Re: [xsl] xpath help?, dvint dvint@xxxxxxxx |
| [xsl] xpath help?, dvint@xxxxxxxxx | Date | Re: [xsl] xpath help?, Michael Kay michaelk |
| Month |