I think there is a bug in the E4X implementation XML.replace function:
Rhino 1.7 release 2 2009 03 22
js> <xml><one/><br/><two/><br/><three/><br/></xml>.replace('br','')
<xml>
<one/>
<br/>
<two/>
<three/>
</xml>
js>
AFAIK the code should remove all the <br/> nodes, but the first one
remains. I also tested in FF3.6 and there the <br/> nodes are properly
removed.
I experienced this in 1.6r7 as well.
P.