Search code examples
xmlactionscript-3flashxml-parsingair

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


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?


Solution

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