path[1].innerHTML
returns
<path d="M 5,10 l0,0 l 15 ,0l0,15l-15,0l0,-15 z" ....
The first 2 digits after M are the x,y coordinates for the starting point of the SVG path.
path[1].innerHTML.substr(10,2)
returns the x cordinate (5) and
path[1].innerHTML.substr(13,2)
returns the correct y coordinate. The problem is the values may be single or double or triple digit numbers which will break the substr() way of doing it.
A simple way is to split your string based on its known format, and get your x,y where you expect them:
You can also use regex, but it may not be simpler.
Use the
pathSegList
interface:Browsers have a parser built in, use it or you'll just spend your life on wheel reinventing and bugfixing.
Note for Chrome, you'll need to use a polyfill