在具有逃生字符的字符串中,如何使用XPath获取元素?
我有这样的html。
<div id="video1" value="<iframe src="https://www.move.com/99"></iframe>"
class="movie"></div>
我想通过使用XPath获取URL [https://www.movie.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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果外部文档的属性或文本节点中有转义的 XML 文档,那么使用 XPath 探测内部文档的唯一方法就是首先解析它。在 XPath 3.1 中您可以这样做
,但在较旧的 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
but that's not possible in older XPath versions.
一种简单的方法是使用类似的子字符串函数:
此表达式选择
@value 属性。
An easy approach would be using substring functions like this:
This expression selects the string between two quotes (
"
="
) of the@value
attribute.