XML Edit text content ?

Discussion about writing code for Inkscape.
ChaudharyParesh
Posts: 5
Joined: Thu Aug 25, 2011 6:21 pm

XML Edit text content ?

Postby ChaudharyParesh » Sun Jul 01, 2012 7:46 pm

Hi,

I want to replace text content from code. with out using xml editor.

Like if i draw Text 'I' on inkscape. using XML Editor i can replace any text on 'I'

But if doing same operation from coding then how's it's possible ?

Ailurus
Posts: 115
Joined: Fri Oct 22, 2010 9:53 am
Location: The Netherlands
Contact:

Re: XML Edit text content ?

Postby Ailurus » Mon Jul 30, 2012 5:38 am

Hmm, without using the XML editor, I'd use something called regular expressions (on Linux there is the sed command, I'm not sure about Windows)...

But I'm not sure whether you'd like to do this inside Inkscape (i.e. using an extension), or from the outside (i.e. just manipulating the SVG file)? What exactly do you mean with the "... from code ..." part in your post?

jazzynico
Posts: 3
Joined: Sun Jul 10, 2011 5:11 pm

Re: XML Edit text content ?

Postby jazzynico » Tue Jul 31, 2012 11:20 pm

Ailurus wrote:on Linux there is the sed command, I'm not sure about Windows

Some GNU tools have been ported to Windows by the GNUwin project. Sed is available at http://gnuwin32.sourceforge.net/packages/sed.htm

Jelle
Posts: 78
Joined: Sat Nov 06, 2010 11:25 am

Re: XML Edit text content ?

Postby Jelle » Tue Sep 04, 2012 7:20 pm

Ehhmm,.. how about doing that with javascript, document.getAttributeNS(null,"text") and then replacing the childNode.value (as the text is actually a childNode of the text element). It actually is quite easy to do that in javascript. On pilat.free.fr and learnsvg.org you can find both a very good book on the topic and a set of tutorials that will tell you exactly what methods to use and a code example.


Return to “Programming”