Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.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
XPath提取标记内的文本_Xpath_Html Parsing - Fatal编程技术网

XPath提取标记内的文本

XPath提取标记内的文本,xpath,html-parsing,Xpath,Html Parsing,HTML结构如下所示: <div class="Parent"> <div id="A">more tags and text</div> <div id="B">more tags and text</div> more tags <p> and text </p> </div> 更多标签和文本 更多标签和文本 更多标签 和文本 我想提取文本只是从家长和标签除了A和B的

HTML结构如下所示:

<div class="Parent"> 
  <div id="A">more tags and text</div>  
  <div id="B">more tags and text</div> 
  more tags
  <p> and text </p>
</div>

更多标签和文本
更多标签和文本
更多标签
和文本

我想提取文本只是从家长和标签除了A和B的孩子。 我试过了 /div[@class='Parent']//text()

它从所有子节点中提取文本,因此a生成了一个类似于/div[@class='Parent']//text()[not(self::div)]

但这并没有改变任何事情


谢谢你的建议

我已经试过了,但是在这种情况下,我没有像这样在标签中看到文本
/div[@class='Parent']/*[not(self::div and (@id='A' or @id='B'))]//text() | /div[@class='Parent']/text()