I will add to this list as I find a need, or as my memory plagues me:
- 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.
- 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]);
}
}
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.