4 Replies Latest reply on Jun 9, 2017 9:27 AM by ekoraichi-2 RSS
    joshuahes Newbie

    How to access XML attributes

    I have loaded some XML from an external source and the info I need is listed as an attribute on the xml group node.


    How can the script access the XML attributes using the getXML snippet. I have tried accessing it with brackets "group["name"]" with no luck

     

    example XML: <groups>

        

    <

    group

    name

    = "name1"

    >url<

    /group

    >

        

    <

    group

    name

    = "name2"

    >url<

    /group

    >

        ...

    I'm unsure how to access the attribute name using the getXML code. I am able to retrieve the url so I know that part of the code is working.


    CODE:

    var configXML = Resources["ContentLoaderFunctions"].GetXML(params);


    var groups = [];


    for each (var group in configXML.groups.group){

        groups.push(group);

    }


    var result = groups.join(",");