Get XML values according to given XPath

xmlSearch(xmldoc, xpathstring) → returns array

xmlSearch Argument Reference

xmldoc xml

XML document object

xpathstring string

XPath expression

Links more information about xmlSearch

Examples sample code invoking the xmlSearch function

Read specific properties from XML collection

XPath extracts 'name' property from every user given in the XML collection

<cfsavecontent variable="xmlstring">
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
        <user id="1">
        <user id="2">
                <street>Long Road</street>
    xml = XMLParse(xmlstring);
    result = xmlSearch(xml,'users//name');
    userlist = '';
    for(i = 1; i <= ArrayLen(result); i++) {
        userlist = ListAppend(userlist,result[i].XmlText);

Expected Result: Me,You

Fork me on GitHub