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
获取XPath内部文本,但不包含部分但不是全部子级_Xpath_Xhtml - Fatal编程技术网

获取XPath内部文本,但不包含部分但不是全部子级

获取XPath内部文本,但不包含部分但不是全部子级,xpath,xhtml,Xpath,Xhtml,我有一些像这样的HTML <div> <a>link that I do not want to get</a> <div>Div that I do not want to get</div> Text I want to get <br> I like brs <b>That text I also want, because I like bold text</b> &l

我有一些像这样的HTML

<div>
  <a>link that I do not want to get</a>
  <div>Div that I do not want to get</div>
  Text I want to get
  <br> I like brs
  <b>That text I also want, because I like bold text</b>
  <div>I do not want all divs</div>
</div>

我不想得到的链接
我不想得到的Div
我想要的文本

我喜欢brs 我也想要那个文本,因为我喜欢粗体文本 我不想要所有的div
我想使用xpath来提取

Text I want to get
<br> I like brs
<b>That text I also want, because I like bold text</b>
我想要的文本

我喜欢brs 我也想要那个文本,因为我喜欢粗体文本
换句话说,我想要所有的DIV child,但不是a,也不是DIV。
我该怎么做

您可以使用
self::a
检测元素,然后使用
not
排除元素,即:

/div/node()[not(self::a or self::div)]