Friday, 2 January 2015

Change value of an XML object



I am new to perl and cannot quite figure out how to solve this problem.


I have a variable which contains an SVG image in the form of an XML. I need to change the value of the tspan tag in the SVG.


The code is as follows.



my $tempSvgImage =
qw~<?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://ift.tt/IHuy5b">
<svg xmlns="http://ift.tt/nvqhV5" xmlns:xlink="http://ift.tt/PGV9lw" version="1.1" width="3200" height="3200" xml:space="preserve">
<desc>Created with Fabric.js 1.4.0</desc>
<defs></defs>
<g transform="translate(482.36 1400) scale(8 8)">
<text font-family="Arial, Helvetica, sans-serif" font-size="50" font-style="normal" font-weight="normal" text-decoration="none" style="stroke: none; stroke-width: 1; stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: #C9FA51; opacity: 1;" transform="translate(-40.3 49)">
<tspan x="0" y="-32.5" fill="#C9FA51">SampleCode</tspan>
</text>
</g>
</svg>~


In the above code I need to change the value of tspan tag from Sample Code to New value. How am I supposed to do it?


No comments:

Post a Comment