使用SimpleXML获取“Form”元素,其中“input”标签的类型为“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