Using event certain made things work.. =D
I don't suppose you'd know why the following code doesn't get rendered? I
call a replace function using an onload event in the body, which passes
the entire xml document as event (I had expected to get the body node,
but this also works I suppose). So I have in the xml:
<body onload=replace(event)>
And then in the js file I have a replace function that does this:
function replace(e) {
xmldoc = e.target;
replacenodes = xmldoc.getElementsByTagName('replace');
//forward traversal insert
for(var i=0;i<replacenodes.length;i++){
imnode = xmldoc.createElement('img');
imnode.setAttribute('src','add.gif');
var node = replacenodes[i];
var pnode = node.parentNode;
pnode.insertBefore(imnode,node);
}
//reverse traversal delete
for(var i=replacenodes.length-1;i>=0;i--){
replacenodes[i].parentNode.removeChild(replacenodes[i]);
}
}
Now, this works, in the sense that <img src="add.gif"> elements get added
to the source (using a css file to draw the img elements as boxes for
instance shows boxes where they should be), but unlike for instance
adding an element called "p", and it consequently being rendered as a
paragraph upon insertion, the "img" element does not get rendered as an
image...
Any clues?
Much oblidged,
- Mike Kamermans
www.nihongoresources.com