Subject: Re: [xsl] xpath help? From: "Michael Kay michaelkay90@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 12 Feb 2025 22:59:29 -0000 |
//x[1] selects every x that is the first child of its parent. You want (//x)[1]. A well-known gotcha, disguised in your case by that intervening predicate. Michael Kay > On 12 Feb 2025, at 22:54, 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 -> |
---|---|---|
Re: [xsl] xpath help?, John Lumley john.lum | Thread | Re: [xsl] xpath help?, David Birnbaum djbpi |
Re: [xsl] xpath help?, David Carlisle d.p.c | Date | Re: [xsl] xpath help?, David Birnbaum djbpi |
Month |