Hello,
I am trying to process each node from XMLHttpRequest.responseXML and
set the node's 'className' property based on the value of the 'class'
attribute. I have written a recursive function to do this. However,
after the function completes, the node's className properties are not
set. I was under the impression that objects were passed to functions
as references. What have I missed?
Code:
// grab the container node
var node = xmlReq.responseXML.getElementsByTagName('div')[0];
// process node and children
process_node(node);
function process_node(n) {
if ( n.nodeType == 1 ) {
if ( n.getAttribute('class') ) {
n.className = n.getAttribute('class');
alert('set className: '+n.className);
}
for ( var c=n.firstChild; c!=null; c=c.nextSibling ) {
process_node(c);
}
}
}
The XML response text looks like this:
<div class="menu_container">
<div class="menu_closed">Menu Text 1</div>
<div class="menu_closed">Menu Text 2</div>
</div>
Thanks!
shawn