Home > Enterprise >  (AS3/Flash/AIR) How to get value of complex XML element?
(AS3/Flash/AIR) How to get value of complex XML element?

Time:12-07

This sounds simple, but I haven't been able to figure out how to get the value of an XML between its tags if it has complex content.

<myXML>I want this text</myXML>
  <myChild/>

If the XML only had simple content, xml.toString() would do exactly what I needed, but since it has a child it is considered complex and the result includes all the tags. How do I get just the element value for a complex XML?

CodePudding user response:

var xmlText:String;
const textList:XMLList = xml.text();
if (textList.length() > 0) xmlText = textList[0].toString();
else xmlText = "";
  • Related