html - 带有标记的文本的 XPath 字符串连接
问题描述
我的 HTML 代码如下所示:
<td>Known text and something <i>follows</i> or not</td>
<td>Unknown text <b>with some</b> subcontainer(s) or without it</td>
让我们说:
<td>Address line 1 <i>(office)</i> in <b>Dallas</b></td>
<td>1, Main Ave. <b>Dallas</b>, 123456</td>
在上面的示例中,“地址行”是已知文本,“1”可能跟在后面,也可能不在,也可能是“2”或“3”等,并且在任何位置都包含 HTML 标记,甚至在已知文本。“1, Main Ave. Dallas, 123456” 是未知文本,可能在任何地方包含一些超文本标记,也可能不包含。
因此,我需要捕获整个字符串“1, Main Ave. Dallas, 123456”,并为 Screaming Frog SEO Spider 编写以下 XPath 表达式:
//td[starts-with(descendant-or-self::*/text(),'Address line')][1]/following-sibling::*[1]//descendant-or-self::*/text()
除了将输出加入一行之外,它成功地完成了它的工作。猜猜我需要使用字符串连接函数,但是当我是 XPath 的新手时,语法失败了。有人可以帮忙吗?
解决方案
推荐阅读
- three.js - 我想将此垂直图像滑块更改为水平滑块
- c++ - 我们可以在c ++中将整数添加到数组中吗
- swift - Element 的 Swift 通用集合无法转换为 Any 的集合
- angular - 如何实现 Angular 中的图标更改场景?
- ios - 我的应用仅在 iOS 13+ 上的 Testflight 中崩溃
- reactjs - 如何在文本字段中按回车键时停止反应引导/@material ui 在 url 中插入获取参数
- javascript - Onload 和 onmouseout 事件的 Javascript 错误
- ios - Objective-C 如何从其他地方将对象添加到 NSMutableArray?
- javascript - 反应按钮 OnHover 更改数组内的图像
- c# - 在 ASP .Net 的一个 zip 文件夹中下载多个 csv 文件