2

次の内容が与えられます:

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

そして、私のテーマには次のようなものがあります。

<div id="dave" />

#daveどのように私は最初の段落に置き換えますか?私はもう試した:

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

どちらも機能しませんでした....contentかなり深く埋まっていて位置が変わる可能性があるため、XPathを使用することはできません。xPathとは、/div/div/p[1]などを意味します。

4

3 に答える 3

0

CSSセレクターは機能する:first-childはずです-したがって、次のようになります

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

于 2011-10-17T14:16:35.467 に答える
0
<replace css:content=".content p:first-child" css:theme="#dave" />

解決策かもしれません;)ヴィト

于 2011-10-04T14:22:26.833 に答える
0

純粋な xslt ソリューションについては、これを試してください。

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

編集

私は意味しました:

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

また

<replace content="//div[@class='content']/div/p[1]" css:theme="div#dave" />
于 2011-10-04T14:24:20.917 に答える