Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用SimpleXML获取;表格「;具有“的元素”;输入“;标签类型为;密码;?_Php_Html_Xml_Xpath_Simplexml - Fatal编程技术网

Php 使用SimpleXML获取;表格「;具有“的元素”;输入“;标签类型为;密码;?

Php 使用SimpleXML获取;表格「;具有“的元素”;输入“;标签类型为;密码;?,php,html,xml,xpath,simplexml,Php,Html,Xml,Xpath,Simplexml,嗨 我有很多表单组成的网页数据(html转换成xml),我想抓取其中有输入标签的表单,类型为password(不需要直接子项)。考虑下面的示例存储在变量$HTML/P>中 <html> <body> <form> <input type="text" name="foo" /> </form> <form> <table> <tr> <input type="password" name="

嗨 我有很多表单组成的网页数据(html转换成xml),我想抓取其中有输入标签的表单,类型为password(不需要直接子项)。考虑下面的示例存储在变量$HTML/P>中
<html>
<body>

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

<form>
<table>
<tr> <input type="password" name="pass"/> </tr>
</table>
</form>

</body>
</html>
但没有成功:(

谢谢。

试试这个XPath:

//form[descendant::input[@type="password"]]
另一个选择是

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

“//form//input[@type=“password”]”//form,//input用于祖先后代的关系,目标是具有值password的type属性。问题是,在获得password类型的输入元素后,我无法返回到最近的form祖先。
//form//input[@type="password"]/ancestor::form