actionscript 3 - How do I reference xml nodes in AS3 whose names are keywords, like <object>x</object> or <name>x</name>? -
I'm trying to parse some XML in AS3, but I'm trying to call, name 'And' object 'can I avoid these words? Like Shri Krishna has already said, these keywords are not always a problem, then you can use regular syntax.
You can use.
However, in some cases, there were valid XML tags and the attribute names were not valid actions (from the top of my head, this happens when hyphens in your xml structure).
A workaround is using square brackets and / or more verbose method calls.
var xml: XML = & lt; Xml & gt; & Lt; Node-to-hyphen attri-cum-hyphen = "123" & gt; Object 1 & lt; / Node-with-hyphens & gt; & Lt; / XML & gt; Trace (xml ["hyphen with node"]); Trace (xml.child ("node-hyphen"); Trace (xml ["node-hyphen"] attribute ("attr-accompany-hyphen").);
Comments
Post a Comment