Reputation: 1439
For the following html code:
<div hidden>
<svg>
<symbol viewBox=“0 0 8 14” id=“icon-carousel-next”>
<path d=“M1.005 14a1 1 0 01-.71-1.71l5.296-5.288L.296></path>
</symbol>
<symbol viewBox=“0 0 8 14” id=“icon-carousel-prev”>
<path d=“M1.005 14a1 1 0 01-.71-1.71l5.296-5.288L.296></path>
<symbol id=“icon-arrow-right-bold” viewBox=“1.2 2.1 22 21”>
<path d=“M1.005 14a1 1 0 01-.71-1.71l5.296-5.288L.296></path>
</svg>
</div>
The following xpath doesn't return result:
//div/svg/symbol
I've noticed that any manipulation related to symbol element doesn't work. Is there a known issue with this element?
Upvotes: 0
Views: 249
Reputation: 29362
to locate an svg
the first thing that you'd have to write is:
//*[name()='svg']
the moment you write this in the browser console, it will filter out all the SVG
nodes in the HTMLDOM
.
Now you may not be interested in all the SVG nodes
rather you are interested in a specific svg node
. for example, let's say the first symbol in this example:
//*[name()='svg']//*[name()='symbol' and @id='icon-carousel-next']
this should get the job done.
to locate the first path
of first symbol
:
//*[name()='svg']//*[name()='symbol' and @id='icon-carousel-next']//*
This should give you a basic idea and should lead you in the right direction.
Upvotes: 1
Reputation: 33361
svg
, path
etc. are special tag names.
Instead of
//div/svg/symbol
try using
//div/*[name()='svg'/*[name()='symbol']
or
//div/*[local-name()='svg'/*[local-name()='symbol']
Upvotes: 0