I’ve been struggling with XML in Flash for days… I found two pieces of information that really helped me a lot… so I thought I’d share them here.
1. The difference between an element node and a text node!
I found out today that some nodes were classed as element nodes and some are classed as text nodes. What I didn’t know was that the text is a node.
For example in this small XML document:
<conversation> <INTERACTION> <NPC_says> What would you like to order? </NPC_says> <player_says> I would like pizza. </player_says> </INTERACTION> </conversation>
The node conversation, interaction, NPC_says and player_says are all element nodes.
I had thought that NPC_says & player_says would be text nodes… but that is not correct, they are both element nodes. The text inside these tags are text nodes. That is, What would you like to order? is a text node as is I would like pizza.
To reference the text what would you like to order? text, you would reference it as follows:
myXML.firstChild.firstChild.firstChild.firstChild
Previously, I thought it would be referenced by:
myXML.firstChild.firstChild.firstChild.nodeValue
Check out this site for more info: XML basics at www.kirupa.com
http://www.kirupa.com/web/xml/XMLbasics4.htm
2. There is an ignoreWhite property
If you don’t tell your xml documen to ignore white space it can pick up blank spaces and think they are nodes in the XML document.
ignoreWhite property
http://www.actionscript.org/resources/articles/9/1/XML-101/Page1.html
I now think I’m ready to take on the XML scripting of the Gotchi-Sim project for real! Yay!