PHP DOMXPath - 表达式,以选择包含具有某些属性的输入的tr [英] PHP DOMXPath - expression to select a tr that contains an input with certain attribute
问题描述
我有以下结构:
<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屋!