2011-12-21 13 views
2

を検索する逆(上から下まで移動する代わりに、ページの端からは?) もしそうなら、私はこれをどのように行うのでしょうか?XPathが逆で検索するDOM_Document XPathを使用方法、あり

私は、Webサイトのこすりをdoindています。 (下記リンク)。 http://www.sturmfh.com/obit-display.jhtml?DB=update/obits/dbase&DO=display&ID=1189477693_24578

私は3つの死亡記事の段落を掻きたいだけです。だから私はそれが最後に始まり、上に移動するのが最も簡単だと考えました。

+1

あなたがこれを行うと理由を説明:

結果はです。 –

答えて

2

使用

(//p)[position() > count(//p) - 3] 

これは、XML文書内の最後の(最大3つ)p要素を選択します。

XSLT - ベースの検証

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:output omit-xml-declaration="yes" indent="yes"/> 
<xsl:strip-space elements="*"/> 

<xsl:template match="node()|@*"> 
    <xsl:copy-of select="(//p)[position() > count(//p) - 3]"/> 
</xsl:template> 
</xsl:stylesheet> 

問題で参照文書に対して適用される場合、この変換は、XPath式を評価し、選択p要素を出力します。

<p> 
       If you would like to share your thoughts and memories,<br/> we will deliver your message to the family.<br/> 
    <a href="mailto:[email protected]?Subject=For%20the%20Family%20of%20Lyle%20Meier">Click</a> 
    <a href="mailto:[email protected]?Subject=For%20the%20Family%20of%20Lyle%20Meier"> 
     <img src="/images/email_condol.gif" alt="Logo" border="0" align="middle"/> 
    </a> 
    <a href="mailto:[email protected]?Subject=For%20the%20Family%20of%20Lyle%20Meier">here</a>. 
     </p> 
<p>To Request a Tribute Folder 
       <br/> 
    <a href="./obit-foldreq.jhtml?fname=Lyle&amp;lname=Meier">Click</a> 
    <a href="./obit-foldreq.jhtml?fname=Lyle&amp;lname=Meier"> 
     <img src="/images/email_condol.gif" border="0" alt="View" align="top"/> 
    </a> 
    <a href="./obit-foldreq.jhtml?fname=Lyle&amp;lname=Meier">here</a> 
</p> 
+0

が、これは右のトラックに私を設定します、ありがとうございます。 – Frantumn

+0

@Frantumn:あなたは歓迎されています。 –