PHP DOMXPath - 表达式,以选择包含具有某些属性的输入的tr [英] PHP DOMXPath - expression to select a tr that contains an input with certain attribute

查看:133
本文介绍了PHP DOMXPath - 表达式,以选择包含具有某些属性的输入的tr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下结构:

<table>
...
    <tr><td><input name="email" /></td></tr>
...
</table>

问题:根据输入的name属性选择tr的表达式是什么 标签?更具体地说,我想知道是否有办法做到这一点,而不必选择输入,然后上升层次结构 - > parentNode-> parentNode ...提前感谢。

Question: what is the expression to select that tr based on the "name" attribute of the "input" tag? More specifically, I want to know if there is a way to do this without having to select the input and then go up the hierarchy doing ->parentNode->parentNode... Thanks in advance.

推荐答案

使用

//table/tr[td/input/@name = 'email']

选择表的子元素 tr / code>并且有一个孩子 td 有一个孩子输入与arrtibute name 其值为字符串'email'

Select all tr elements that are children of a table and that have a child td that has a child input with arrtibute name whose value is the string 'email'.

注意:表达式中不使用反向轴。

Do note: No reverse axis is used in the expression.

这篇关于PHP DOMXPath - 表达式,以选择包含具有某些属性的输入的tr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆