xmlFindArray

Prev Next

Description

Returns an array of child values at the specified parent XML element location.


Input Parameters

Name Type Required Description
xml Text Yes XML document
path Text Yes Path to target parent XML element, separated by forward slashes (/)
property Text Yes Name of child XML element's attribute; Specifying a dot (.) returns the value of the XML child element instead of an attribute value

Returns

Type: Array

Returns a new array of child values at the specified parent XML element location.


Examples

var xml = "
<Cars>
    <Favorites>
        <Makes>
            <Make Year='2010'>Ford</Make>
            <Make Year='2020'>BMW</Make>
        </Makes>
    </Favorites>
</Cars>";

// returns an array of years ["2010", "2020"]
var items = tools.xmlToArray(xml, "Favorites/Makes", "Year");
debug.log(items);
var xml = "
<Cars>
    <Favorites>
        <Makes>
            <Make Year='2010'>Ford</Make>
            <Make Year='2020'>BMW</Make>
        </Makes>
    </Favorites>
</Cars>";

// returns an array of makes ["Ford", "BMW"]
var items = tools.xmlToArray(xml, "Favorites/Makes", ".");
debug.log(items);

Remarks

None.