Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
xpath计算的问题_Xpath - Fatal编程技术网

xpath计算的问题

xpath计算的问题,xpath,Xpath,如果我只想在Type1下提取HREF,基本上是1,2,3,4。htm但不包括5.htm,如何做到这一点 我现在拥有的是://table[@class='leftnav']//a” 谢谢 <table width="240" border="0" cellpadding="0" cellspacing="0" class="leftnav"> <tr class="leftnav"> <th>Type1</th> </tr>

如果我只想在Type1下提取HREF,基本上是1,2,3,4。htm但不包括5.htm,如何做到这一点

我现在拥有的是://table[@class='leftnav']//a”

谢谢

<table width="240" border="0" cellpadding="0" cellspacing="0" class="leftnav">
  <tr class="leftnav">
    <th>Type1</th>
  </tr>
  <tr class="leftnav">
    <td><a href="/mic/1.htm">2013</a></td>
  </tr>
  <tr class="leftnav">
    <td><a href="/mic/2.htm">2012</a></td>
  </tr>
  <tr class="leftnav">
    <td><a href="/mic/3.htm">2011</a></td>
  </tr>
  <tr class="leftnav">
    <td><a href="/mic/4.htm">2010</a></td>
  </tr>
   <tr class="leftnav">
    <th>Type2</th>
  </tr>
   <tr class="leftnav">
     <td><a href="/mic/5.htm">2013</a></td>
   </tr>
</table>

类型1
类型2
试试这个xpath:

//tr[(preceding-sibling::tr/th)[last()]="Type1"]/td/a