title: JS on SVG--getting innerHTML of an element
body: <p>I wanted to extract some data from an SVG file. I know that SVG is XML, so I thought that it would be pretty easy to coax the data out with JS.</p>
  
  <p>So, I wanted to get a bunch of text extracted from an SVG. So, I fired up chrome's JS console, and tried doing some stuff. I needed to get all the <code>tspan</code> elements in an array, extract their text, and categorize it.</p>
  
  <p>I'm referring to <a href="http://upload.wikimedia.org/wikipedia/commons/e/eb/Light_spectrum.svg" rel="noreferrer">http://upload.wikimedia.org/wikipedia/commons/e/eb/Light_spectrum.svg</a> at the moment.</p>
  
  <p>So, I use <code>a = document.getElementsByTagName('tspan')</code>. Now, I try <code>a[20].innerHTML</code>, and get <code>undefined</code>. Reasonable; it's not HTML and iirc innerHTML is nonstandard anyways.</p>
  
  <p>Then I try <code>a[20].childNodes[0]</code> and get <code>"ELF"</code>. OK, that's what I wanted. But, for some reason, this object is treated like a string, but can't be converted to one. If I try to convert it (so that I can use stuff like <code>matches()</code> and <code>indexOf()</code>), I get <code>"[object Text]"</code>. Delving into <code>Text.prototype</code> doesn't help--I can't find any function that converts it to a string.</p>
  
  <p>So how can one get the innerHTML of an SVG object through JS?</p>