0

次のhtmlタグ構造があります。

<?xml version="1.0" encoding="UTF-8"?><div class="MainContentTextContainer">
<br/> To break the stalemate of heavy competition and low growth in the traditional orthopedic implant markets, the major orthopedic companies are turning to biologics. This white paper provides some information on this trend. Information from this White Paper was obtained from Kalorama's full market study on this market 'The World Market for Orthopedic Biomaterials SKU KLI6329663," as well as news media sources. <br/>
<br/>
<p> "We also feature department and global pricing for reports that we be utilized by more than one user at your company."
</p>
<p>
<b>Related Reports:</b>
</p>
<!-- [PID:6921310] -->
<a href="http://www.kaloramainformation.com/Global-Medical-Devices-6921310/" class="StandardLink DkBlueType">The Global Market for Medical Devices, 3rd. Edition</a>
<br/>May 2, 2012 - KLI3873247 - $1,995.00<br/>
<br/>

</div>

<p>上記は私のhtmlノード構造です。「関連レポート:」を含む最後のタグの後にノードを含まないMainContentTextContainerノードを返したいです。

次のように期待される出力が必要であることを意味します。

<div class="MainContentTextContainer">
    <br/> To break the stalemate of heavy competition and low growth in the traditional orthopedic implant markets, the major orthopedic companies are turning to biologics. This white paper provides some information on this trend. Information from this White Paper was obtained from Kalorama's full market study on this market 'The World Market for Orthopedic Biomaterials SKU KLI6329663," as well as news media sources. <br/>
    <br/>
    <p> "We also feature department and global pricing for reports that we be utilized by more than one user at your company."
    </p>   
    </div>

次のxpathを使用しました:

//div[@class='MainContentTextContainer']/*[not(self::p[last()])]

しかし、それは機能していません。適切な xpath を案内してください。

ありがとう。

4

1 に答える 1

0

この XPath 式はdiv、 が続く内のすべてのテキスト ノードと要素ノードを返しますp。これは、最後pのノードとそれに続くノードが含まれていないことを意味します。

(//div[@class='MainContentTextContainer']/* | //div[@class='MainContentTextContainer']/text())[following-sibling::p]
于 2012-08-28T08:09:09.853 に答える