Skip to main content
Known Participant
September 18, 2012
Answered

Can't access xml tags directly:: Namespace issue

  • September 18, 2012
  • 1 reply
  • 3212 views

It appears that I've found another case of "Flash does (this) great. EXCEPT . . . . . "

I've posted my issue on a couple forums with no replies. Rather than repost I'll just put the link here and hope SOMEBODY has an answer.

http://www.actionscript.org/forums/showthread.php3?p=1137057#post1137057



This topic has been closed for replies.
Correct answer kglad

Namespace requires a small s.

I can now trace responseDeclaration. How do I access its children? How does that code even work for that matter?


oops, you're correct.

i fixed that in message 1 so, you can mark that as correct if you found it helpful.

there are 2 ways a namespace can be used in xml.  the way you are using it, the namespace applies to each and every node within the xml.

to reference each of every node (but not attribute) you must use the namespace string:

trace(xml.s::responseDeclaration.s::mapping.s::mapEntry.@mapKey);

trace(xml.s::responseDeclaration.s::mapping.s::mapEntry.(@mapKey=="A").@mappedValue);

1 reply

kglad
Adobe Expert
September 18, 2012

you need to use that namespace to reference xml elements.  try:

var s:Namespace=xml.namespace();

trace(xml.s::responseDeclaration);

lheinem99Author
Known Participant
September 18, 2012

putting your code in throws an error:


1046: Type was not found or was not a compile-time constant: NameSpace.
kglad
Adobe Expert
September 19, 2012

kglad, you're the man. Over the past 3 years I've posted probably a half dozen problems on various sights, and you are officially the first one to answer any of them with a solution. (well maybe 2nd, but still)

I tip my hat to you. Thanks!


you're welcome!