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
精彩评论