开发者

Getting href from parent anchor HtmlUnit

开发者 https://www.devze.com 2023-03-05 23:23 出处:网络
What I am trying to do is to use HtmlUnit to get the href from the parent anchor of a span. Here is what I mean.

What I am trying to do is to use HtmlUnit to get the href from the parent anchor of a span. Here is what I mean.

  <a href="http://link.com/serv?id=jibberish&type=dynamic/changeseachvisit"&开发者_运维知识库gt;<span>Some Unique Text</span></a>

There is no id or name associated with either the or the tags, so going by this example, how would you find that link in a sea of others like it without ids or names? Thanks!


use the XPATH //span[contains(.,'Transcript')]/parent::a/@href

(non tested, but XPATH is definitely the way to go)

0

精彩评论

暂无评论...
验证码 换一张
取 消