1 Reply Latest reply: Aug 12, 2012 10:06 AM by Aegis Kleais RSS

    How to reference a value in an XML file

    Aegis Kleais Community Member

      Hey guys!  I have a valid XML structure, and in it is the following info:

       

      <app>
           <settings>
                <setting name="defaultModuleSlug" value="apples"></setting>
                <setting name="defaultPageSlug" value="oranges"></setting>
           </settings>
      <app>
      

       

      The XML info is in an application object called application.config.

       

      So, How do I reference the defaultPageSlug variable?  I know I can use:

       

      application.config[ 'app' ][ 'settings' ].xmlChildren[ 2 ].xmlAttribute[ 'value' ]
      

       

      However, I'd like to be able to reference the setting by it's name attribute (defaultPageSlug) and not assuming it's the 2nd element in that node.  Can someone help?