Introduction to XML in Flash
by senocular
What about Attributes?
Attributes are not forgotten. They are just
more "manual". The attributes object
can be manually edited just as any other object
in Flash and does not require methods to alter
it. This makes them easy to work with as you
don't necessarily have to deal with potentially
confusing XML methods. Example:
- var my_xml
= new
XML("<friends><friend
/></friends>");
- my_xml.firstChild.firstChild.attributes.girlfriend
= "Julie"
- trace(my_xml);
// traces "<friends><friend
girlfriend="Julie" /></friends>"
-
- delete my_xml.firstChild.firstChild.attributes.girlfriend;
- trace(my_xml);
// traces "<friends><friend
/></friends>"
Working with attributes is probably more easy
than anything else. Because of this, people
like to stick everything into attributes, but,
as I said before, you should keep it simple.
|