在具有逃生字符的字符串中,如何使用XPath获取元素?

发布于 2025-01-17 21:09:29 字数 304 浏览 3 评论 0原文

我有这样的html。

<div id="video1" value="&lt;iframe src=&quot;https://www.move.com/99&quot;&gt;&lt;/iframe&gt;"
class="movie"></div>

我想通过使用XPath获取URL [https://www.movi​​e.com/99]。

但是,逃生角色和其他角色使它变得困难。

如何通过使用XPATH或其他方式来获取它。

I have a html like this.

<div id="video1" value="<iframe src="https://www.move.com/99"></iframe>"
class="movie"></div>

I want to get url [ https://www.movie.com/99 ] by useing Xpath.

However, the escape characters and other make it difficult.

How to get it by useing Xpath or other means.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

美人如玉 2025-01-24 21:09:29

如果外部文档的属性或文本节点中有转义的 XML 文档,那么使用 XPath 探测内部文档的唯一方法就是首先解析它。在 XPath 3.1 中您可以这样做

parse-xml(div/@value)/iframe/@src

,但在较旧的 XPath 版本中这是不可能的。

If you have an escaped XML document within an attribute or text node of an outer document, then the only way you can use XPath to probe into the inner document is to parse it first. In XPath 3.1 you can do

parse-xml(div/@value)/iframe/@src

but that's not possible in older XPath versions.

一向肩并 2025-01-24 21:09:29

一种简单的方法是使用类似的子字符串函数:

substring-before(substring-after(div[@id='video1' and @class='movie']/@value,'"'),'"')

此表达式选择@value 属性。

An easy approach would be using substring functions like this:

substring-before(substring-after(div[@id='video1' and @class='movie']/@value,'"'),'"')

This expression selects the string between two quotes ("= ") of the @value attribute.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文