Example provided by Juliana Williams and Andreas Neumann
The DOM is a language-neutral API (Application Program Interface) that allows any programming language to access, manipulate, create, and delete elements and the document tree. DOM manipulations work the same way in all W3C/XML documents and are not SVG specific. If you know how to manipulate HTML documents using ECMAScript and the DOM, it will be easy for you to manipulate SVG documents. ECMAScript is the most popular scripting language in web browsers and SVG Viewers, hence we use it for our tutorials.
The following code shows a very simple SVG document containing only a rectangle and a text element.