Reputation: 44345
In a webpage containing the following piece of code:
...
<svg class="main-svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1394" height="450" style="background: rgb(255, 255, 255) none repeat scroll 0% 0%;">
<defs id="defs-a3c0aa">
<g class="clips">
<clipPath class="axesclip" id="clipa3c0aax">
<rect x="40" y="0" width="1274" height="450">
....
I use the 'Try XPath' extension to search for an xpath, and I try the following expression:
//svg
but no hit comes back. The number of found elements is zero. And there is NO iframe in that page somwhere.
So what could be going on? (I cannot post the page as it is not public)...
Upvotes: 1
Views: 125
Reputation: 11182
You better use below xpath
//*:svg
it means all descendants having any namespace and its local-name is svg
.
//*[local-name() = 'svg']
Above one also would work. Hope this helps...
Upvotes: 1
Reputation: 241928
The <svg>
element has a namespace. You need to register the namespace with a prefix, and specify the prefix in XPath. For example, if you register the prefix s
for http://www.w3.org/2000/svg
, the XPath expression will become
//s:svg
The way how to register the namespace depends on what language you're using.
Upvotes: 0