Load a svg file(xml) and extract specific information using javascript

haikal

New Member
I am trying to get a svg file using jquery/javascriptsvg example:\[code\]<svg width="111" height="123" xmlns="http://www.w3.org/2000/svg"> <g> <title>Layer 1</title> <rect fill="#ffffff" stroke="#000000" stroke-width="3" x="1.5" y="1.5"width="108.00001" height="119.99999" id="svg_1" rescale="none" move="Static"/> <text text_pos="midcenter" xml:space="preserve" text-anchor="middle" font-family="Fantasy" font-size="14" id="Actor Role name" y="68" x="55" stroke-width="0" stroke="#000000" fill="#000000" rescale="none" move="Static">Actor Role</text></g></svg> \[/code\]And using something like this to extract the data from a file\[code\] $.get(file_url, function(data) { var teste=data; },'xml')// or use text instead of xml\[/code\]then get all the elements like rect or textand say get something like(exclude the inside ' ' just to know where the values come from):'Element' rect, 'rescale' none, 'move' staticand for text(exclude the inside ' '): 'Element' rect, 'rescale' none, 'move' static, 'text_pos' midcenter ,'id' Actor Role name, 'node value' Actor Role
 
Top