开发者

Using SimpleXML to get "Form" element which have "input" tag with type "password"?

Hi I have webpage data (html converted into xml) consisting of many forms , I want to grab the form which have input tag inside it of type password ( not necessary direct children) . consider example below data stored inside variable $html

<html>
<body>

<form>
<input type="text" name="foo" />
</form>

<form>
<table>
<tr> <input type="password" name="开发者_运维知识库pass"/> </tr>
</table>
</form>

</body>
</html>

I tried

$loginForm  =  $html->xpath('//form//input[@type="password"]//../form'); 

But didnt succeeded :(

Thanks.


Try this XPath:

//form[descendant::input[@type="password"]]


Another option is

//form//input[@type="password"]/ancestor::form
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜