开发者

Select first child <p> in Deliverance

Given the following content:

<div class="content">
  <div id="brian">
    <p>Hell开发者_Python百科o 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:

  • <replace content="//div[@class='content']/p" theme="div#dave" />
  • <replace content="//div[@class='content']/p[1]" theme="div#dave" />
  • <replace content="children://div[@class='content']/p" theme="meta#description" />

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...


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

Could be the solution ;) Vito


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" />


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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜