I am working on a thing which will need to get at the path data of individual paths in an SVG
file, so that I can generate similar paths.
After looking in horror at the plethora of c/c++ libraries for handling SVG files, I decided to use perl (since it is more suited to the job of sorting through sausages of SVG path data) with an XML parser. For some reason I chose XML::Easy
(I had a good reason. That was yesterday and I can't remember what it was. Probably the fact that it's supposed to be Easy
) as the parser.
However, I have not found any tutorials or documentation other than perldoc and metacpan.
I have managed to read my file into an XML::Easy::Element
reference using xml10_read_document
, but I have no idea how to get at the actual path data.
How do I get the path sausage from the XML::Easy::Element
reference?
Edit: the sausage I am referring to is the d attribute in the path. EG: from
<svg>
[...]
<g id=something>
<path d="M350.41,62.567v0.135l1.118,0.04v-0.135L350.41,62.567z
M351.898,60.655c-0.242,0-0.433,0.059-0.572,0.175c-0.089,0.104-0.179,0.207-0.269,0.311l-0.014-0.445l-0.875-0.013v0.31
l0.458,0.067l-0.041,1.421l0.498,0.006l0.014-0.754c0.197-0.449,0.438-0.673,0.72-0.673c0.193,0,0.29,0.11,0.29,0.329
c0,0.108-0.025,0.223-0.074,0.344l0.316,0.081c0.085-0.148,0.128-0.312,0.128-0.491c0-0.185-0.047-0.34-0.142-0.465
C352.228,60.723,352.082,60.655,351.898,60.655z
M350.572,62.816l-0.027,0.922l0.525-0.08l0.006-0.835L350.572,62.816z"/>
</g>
[...]
</svg>
I would like to extract
"M350.41,62.567v0.135l1.118,0.04v-0.135L350.41,62.567z
M351.898,60.655c-0.242,0-0.433,0.059-0.572,0.175c-0.089,0.104-0.179,0.207-0.269,0.311l-0.014-0.445l-0.875-0.013v0.31
l0.458,0.067l-0.041,1.421l0.498,0.006l0.014-0.754c0.197-0.449,0.438-0.673,0.72-0.673c0.193,0,0.29,0.11,0.29,0.329 c0,0.108-0.025,0.223-0.074,0.344l0.316,0.081c0.085-0.148,0.128-0.312,0.128-0.491c0-0.185-0.047-0.34-0.142-0.465
C352.228,60.723,352.082,60.655,351.898,60.655z
M350.572,62.816l-0.027,0.922l0.525-0.08l0.006-0.835L350.572,62.816z"