Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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
Html xpath来查找特定节点下面的文本框,该节点又包含特定的子节点_Html_Xpath - Fatal编程技术网

Html xpath来查找特定节点下面的文本框,该节点又包含特定的子节点

Html xpath来查找特定节点下面的文本框,该节点又包含特定的子节点,html,xpath,Html,Xpath,我费了好大劲才为这本书写了一个标题 下面是我正在解析的示例HTML,为了简洁起见,将其部分截断,但希望有人能够理解我在寻找什么 我希望在示例代码的最底部识别输入。 我不能使用ID,因为它不断变化。i、 e.id=“id\u mstr111\u txt” 让我用英语尽可能地描述一下我想达到的目的: 查找输入 …在具有作为后代的DIV的class=“mstrPromptQuestion”下 。。。。。。spanclass=“mstrpromptQuestionTitlePartitle”>摘要期间

我费了好大劲才为这本书写了一个标题

下面是我正在解析的示例
HTML
,为了简洁起见,将其部分截断,但希望有人能够理解我在寻找什么

我希望在示例代码的最底部识别
输入。
我不能使用
ID
,因为它不断变化。i、 e.
id=“id\u mstr111\u txt”

让我用英语尽可能地描述一下我想达到的目的:

查找
输入

…在具有作为后代的
DIV
class=“mstrPromptQuestion”

。。。。。。span
class=“mstrpromptQuestionTitlePartitle”>摘要期间

或者用另一种方式写:

给定一个包含深度嵌入子节点的
DIV
class=“mstrPromptQuestion”
:span
class=“mstrpromptquestiblettitlebattle”>抽象时段
查找
输入
(不使用
ID
,因为数字随每次构建而变化)

我不确定使用
XPath 2.0
和没有
jquery
——只使用基本的
XPath
函数是否可以做到这一点


2.
抽象时期**
(必选)

对于以英语描述的:

//div[@class='mstrPromptQuestion'][.//span[@class='mstrPromptQuestionTitleBarTitle']]//input[contains(@id, '_txt')] 结果是:

//div[@class='mstrPromptQuestion'][.//span[@class='mstrPromptQuestionTitleBarTitle'][contains(text(), 'Abstracted Period')]]//input[contains(@id, '_txt')]
(//div[@class='mstrPromptQuestion']//input)[last()]
//div[@class='mstrPromptQuestion'][.//span[@class='mstrpromptQuestionTitlePartitle'][contains(text(),'Abstracted Period')]]//input[contains(@id,'.-txt')]
如果您确定这是
div
中的最后一个
输入
,您可以执行以下操作:

//div[@class='mstrPromptQuestion'][.//span[@class='mstrPromptQuestionTitleBarTitle'][contains(text(), 'Abstracted Period')]]//input[contains(@id, '_txt')]
(//div[@class='mstrPromptQuestion']//input)[last()]
或者类似于:

(//div[@class='mstrPromptQuestion' and .//span[@class='mstrPromptQuestionTitleBarTitle']='Abstracted Period']//input)[last()]

如果
mstrpromptQuestionTitlePartitle
很重要。

我试过这个,它似乎起作用了//div[@class='mstrPromptQuestion'和//span[@class='mstrpromptQuestionTitlePartitle'和text()='Abstracted Period']//输入