How to use insertBefore to add a new element?
<p>I'm trying to add text to a  tag but I keep getting an error</p>

<pre><code>NOT_FOUND_ERR: DOM Exception 8
Error: An attempt was made to reference a Node in a context where it does not exist.
</code></pre>

<p>Here's the javascript:</p>

<pre><code>var getexp = document.getElementsByTagName("td")[219];
few lines of code here...
var fsptag = document.createElement('text');
fsptag.innerHTML = append1 +fspRound +append2 +ratioRound;

var fsptext = fsptag.innerHTML;
fsptag.appendChild(fsptext);
getexp.insertBefore(fsptag,getexp.childNodes[10]);
</code></pre>

<p>I'm new to this (only a few days). From what I understand <code>getexp.childNodes[10]</code> should be a child node of <code>getexp</code>. And it is a child node.
Any help here would be appreciated. Thanks.</p>

<p>EDIT: HTML</p>

<pre><code>&lt;td colspan=2&gt;&amp;nbsp;&amp;raquo;&amp;nbsp;
&lt;b&gt;Combat level: 20&lt;/b&gt; (311855484)&amp;nbsp;&lt;font style='font-size:8px;color:#696156'&gt;+13144516&lt;/font&gt;
&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;raquo;&amp;nbsp;
&lt;b&gt;Troops ready:&lt;/b&gt; 100% 
&lt;BR&gt;&amp;nbsp;&amp;raquo;&amp;nbsp;
&lt;b&gt;Mana:&lt;/b&gt; 40 / 40&lt;BR&gt;&amp;nbsp;&amp;raquo;&amp;nbsp;
&lt;b&gt;Location:&lt;/b&gt; &lt;a href=map.php?cx=50&amp;cy=50&gt;Empire Capital&lt;/a&gt;
&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;
&lt;center&gt;&lt;object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="460" height="54" id="showarmy" align="middle"&gt;
</code></pre>

<p>The HTML looks something like this. It's from here (<a href="http://www.lordswm.com/pl_info.php?id=2255" rel="nofollow">http://www.lordswm.com/pl_info.php?id=2255</a>) in the source about line 204.</p>

<p>Edit:</p>

<pre><code>var append1 = "&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;raquo;&amp;nbsp;&lt;b&gt;Total FSP: &lt;/b&gt;";
var append2 = "&lt;br&gt;&amp;nbsp;&amp;raquo;&amp;nbsp;&lt;b&gt;Ratio: &lt;/b&gt;";
var fsptag = document.createElement('text');
fsptag.innerHTML = append1 +fspRound +append2 +ratioRound;       //fspRound &amp; ratioRound are numbers
</code></pre>

<p>Then when I use this: <code>getexp.appendChild(fsptag);</code> the appended text(html?) is created at the end i.e. after the <code>&lt;object&gt;</code> (last line in html code). I want it to appear in between the 5 <code>&lt;br&gt;</code> tags (line 8 of html code).
Sorry for delaying, I was trying to figure it out myself.</p>
