PDA

View Full Version : how do you delete xml attributes?


octothorp
05-28-2002, 07:24 PM
ok, this probably ranks as the stupidist question I've asked on here yet. A list of attributes is an array, right? So I should be able to delete an attribute using 'splice', right? If there is an easier way of deleting an attribute, please let me know.
So anyway, I write this code, which is supposed to iterate through a list of attributes, find the one that is to be delete, and deletes it. It does these first two steps, but I can't delete my freakin' attributes!

var count = 0;
//iterate through attributes
for (var prop in nodeRef.attributes) {
//find attribute that matches the attribute to be deleted
if (prop == attName) {
//delete the attribute
nodeRef.attributes.splice(count, 1);
}
count++;
}

Any help is regards to what I'm doing wrong would be greatly appreciated.

#

Jesse
05-28-2002, 11:58 PM
The attributes are actually names array objects which in Flash makes the attributes array less like an array and more like and array-like Object.
You shold simply be able to do:
delete nodeRef.attributes.attributeName;

octothorp
05-29-2002, 03:28 PM
See, I knew it was going to be a simple answer, I just couldn't find an example of the code to use for it anywhere. Many thanks for your help!

#