# getElementById on a SVG object

**URL:** <https://www.ruby-forum.com/t/getelementbyid-on-a-svg-object/100138>\
**Category:** Ruby\
**Created:** [July 27, 2006, 11:17am UTC](https://www.ruby-forum.com/t/getelementbyid-on-a-svg-object/100138 "2006-07-27T11:17:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![guillaume](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c67d28/32.png) [@guillaume](https://www.ruby-forum.com/u/guillaume)\
**Post date:** [July 27, 2006, 11:17am UTC](https://www.ruby-forum.com/t/getelementbyid-on-a-svg-object/100138/1 "2006-07-27T11:17:06Z")

</div>

Hi all, I would like to know if it is possible to retreive a SVG object  
(in fact an image in a vector format that needs aa Adobe plugin to be  
displayed) by writing something like

mySVGObject = ie.document.getElementById(SVGId);

?

Then if it works, is it possible to explore the SVG XML tree with the  
same getElementById method (SVG image is represented as an XML file).

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![guillaume](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c67d28/32.png) [@guillaume](https://www.ruby-forum.com/u/guillaume)\
**Post date:** [July 27, 2006, 12:11pm UTC](https://www.ruby-forum.com/t/getelementbyid-on-a-svg-object/100138/2 "2006-07-27T12:11:24Z")

</div>

You might get some answers on a Javascript or SVG forum.

Cheers  
Nic

---

<div class="post-metadata">

**Author:** ![guillaume](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c67d28/32.png) [@guillaume](https://www.ruby-forum.com/u/guillaume)\
**Post date:** [July 27, 2006, 7:05pm UTC](https://www.ruby-forum.com/t/getelementbyid-on-a-svg-object/100138/3 "2006-07-27T19:05:20Z")

</div>

Guillaume Rosset wrote:

> Hi all, I would like to know if it is possible to retreive a SVG object  
> (in fact an image in a vector format that needs aa Adobe plugin to be  
> displayed) by writing something like
> 
> mySVGObject = ie.document.getElementById(SVGId);
> 
> ?
> 
> Then if it works, is it possible to explore the SVG XML tree with the  
> same getElementById method (SVG image is represented as an XML file).

Look at the API for REXML, the XML parser that comes with Ruby.

[http://www.ruby-doc.org/stdlib/libdoc/rexml/rdoc/](http://www.ruby-doc.org/stdlib/libdoc/rexml/rdoc/)

For example

my\_xml\_dom\_obj.elements.to\_a( “//[@id=#{SVGId}]” ).first

–  
James B.

“To predict the behavior of ordinary people in advance, you only have to  
assume that they will always try to escape a disagreeable situation with  
the smallest possible expenditure of intelligence.”  
- Friedrich Nietzsche
