xpath を使用して、別の div 内にある div ノードを取得したい:
私の入力は次のとおりです。
<div id="toolbar">
<div class="linkTrail">
<span class="trailLabel">You are here: </span>
<a href="http://www.euromonitor.com/home">Home</a>
<a href="http://www.euromonitor.com/solutions">Solutions</a>
<a href="http://www.euromonitor.com/industries">Industries</a>
<a href="http://www.euromonitor.com/home-care" class="last">Home Care</a>
</div>
<script type="text/javascript">var switchTo5x = false;</script>
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript"> stLight.options({ publisher: 'c4fa7e97-6938-4efa-b3d0-b81551cc9ee3', tracking: 'google' });</script>
<div class="clear">
</div>
次のように出力したい:
<div class="linkTrail">
<span class="trailLabel">You are here: </span>
<a href="http://www.euromonitor.com/home">Home</a>
<a href="http://www.euromonitor.com/solutions">Solutions</a>
<a href="http://www.euromonitor.com/industries">Industries</a>
<a href="http://www.euromonitor.com/home-care" class="last">Home Care</a>
</div>
linktrail divを取得するために、xpathに続いてxpathを試しました:
//div[@class='toolbar']/div
しかし、間違った出力が得られます:
<div class="linkTrail">
<span class="trailLabel">You are here: </span>
<a href="http://www.euromonitor.com/home">Home</a>
<a href="http://www.euromonitor.com/solutions">Solutions</a>
<a href="http://www.euromonitor.com/industries">Industries</a>
<a href="http://www.euromonitor.com/home-care" class="last">Home Care</a>
</div>
<script type="text/javascript">var switchTo5x = false;</script>
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript"> stLight.options({ publisher: 'c4fa7e97-6938-4efa-b3d0-b81551cc9ee3', tracking: 'google' });</script>
問題になる可能性があるのは、親 div にスクリプトが含まれているためです。誰でもこの問題を理解するのを手伝ってくれますか?