我想使用 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>
我在 xpath 之后尝试了 xpath 来检索 linktrail div:
//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 包含脚本。谁能帮我解决这个问题。