Alex
Alex

Reputation: 9041

Select first child <p> in Deliverance

Given the following content:

<div class="content">
  <div id="brian">
    <p>Hello my name is Alex</p>
    <p>My surname is Thomas</p>
    <p>My middle name is James</p>
    <p>true story...</p>
  </div>
</div>

And with the following in my theme:

<div id="dave" />

How so I replace #dave with the first paragraph? I've tried:

Neither worked... Please note that .content is buried fairly deep and can change position, so using its XPath is not an option. By xPath I mean /div/div/p[1] etc...

Upvotes: 2

Views: 175

Answers (3)

ejucovy
ejucovy

Reputation: 947

The :first-child CSS selector should work -- so it would be something like

<replace content="p:first-child" theme="#dave" />

Upvotes: 0

Giacomo Spettoli
Giacomo Spettoli

Reputation: 4496

For a pure xslt solution try this:

<replace content="//div[@class='content']/p[1]" theme="div#dave" />

edit:

i meant:

 <replace content="//div[@class='content']//p[1]" css:theme="div#dave" />

or

<replace content="//div[@class='content']/div/p[1]" css:theme="div#dave" />

Upvotes: 0

Vito
Vito

Reputation: 1201

<replace css:content=".content p:first-child" css:theme="#dave" />

Could be the solution ;) Vito

Upvotes: 0

Related Questions