I have a html like this.
<div id="video1" value="<iframe src="https://www.move.com/99"></iframe>"
></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.
CodePudding user response:
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.
CodePudding user response:
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.