I will add to this list as I find a need, or as my memory plagues me:

    • var xl:XMLList = new XMLList( xml.toXMLString() ); – convert XML to XMLList
    • var xml:XML = new XML( “<data>” + xmlList.toXMLString() + “</data>” );– convert XMLList to XML with root “data”.
      • An XMLList is a list of separate XML objects. “<data></data>” is added here to make it well-formed XML.
    • xml.attributes()[idx] – Treating attributes, children, comments, descendants, elements, text, etc. as an array. The original output is an XMLList.
    • xml.attribute(“*”)[idx] – Treating attribute, child, comments, and others that use parameters as an array. The original output is an XMLList.
    • name() – Retrieving the name of the current XML object – the name of an attribute, element, or other XML non-data names.
    • xml.attributes()[idx].name() – Retrieving the name of an attribute.
    • xml.someElementName.(@id == marker).child(“*”) – Retrieve all children of all elements whose “id” attribute match the “marker” variable.
    • xml.elements(“someElementName”) – Retrieve an element by the element’s name. Returns a new XMLList of the element and it’s children.
    • xml.elements()[i] – access some specific element.
      • NOTE: This returns an XML object, not an XMLList object.
    • Make an array out of XML.
    • length() – Get number of entries from some XML object (Array uses length (no parentheses), which is confusing at times)

A simple for-loop looks like this:

if ( xmlBase
    && xmlBase.someElement
    && xmlBase.someElement.multipleElementsArea
    && xmlBase.someElement.multipleElementsArea.length() > 0
    trace("all elements = " + xmlBase.someElement.multipleElementsArea);
    var val:int = xmlBase.someElement.multipleElementsArea.length();
    for (var i:int = 0; i < val; i++)
        trace( "some attribute value: " + xmlBase.someElement.multipleElementsArea[i].@attribute);
        trace( "some element value: " + xmlBase.someElement.multipleElementsArea[i]);
  • xml.entryItem.(@attribute1 == “someValue”).@attribute2[indexInt] – This returns data stored in an attribute contained within the same element as the searched attribute.
    Returns the value stored in an attribute named attribute2 within an XML element entryItem, where initially the list is sorted by attribute1. Useful in a for loop. This is similar to a horizontal lookup command in a spreadsheet.
  • var xml:XML = <elementName attr1={someVariable} attr2={someOtherVariable}>{variableForTheText}</elementName> – Using variables in implicit XML. Adds attributes and element text via variables. Note: Quotation marks are automatically added to attributes (around someVariable and someOtherVariable), but not added to element info (variableForTheText).

– 30 –