0
我想使用xpath并且难以从下面的html代码调用表元素。xpath选择最接近的表来锚定标记名称
在html中会有很多表格。我感兴趣的是最接近锚定标签的名字。
下面的html部分仅仅是我正在处理的html语法的一个粗略概念。
<body>
.
.
.
.
.
<p>
<font><b><a name="myTable" /></b></font></p>
<p><b></p>
<div><p></p></div>
<table>
:
:
:
</table>
.
.
..
我最初是通过调用锚标记获取父,然后调用一个同级几次我达到表要回“P”元素。 我知道这不是聪明的做法。还有一个问题是可以有变量的兄弟姐妹。 所以我所知道的肯定是我必须看看的表是最接近标签名称的标签。
有人可以提出一些想法吗?
我尝试这样做:
getByXPath("//a[@name=myTable]/table"); (it wont work because it goes to anchor tag and looks for table in children of anchor tag. But it is not the case here)