Skip to main content
Inspiring
August 10, 2012
Answered

How to reference a value in an XML file

  • August 10, 2012
  • 1 reply
  • 474 views

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?

    This topic has been closed for replies.
    Correct answer Aegis_Kleais

    Nevermind, I guess I can just use XPath.

    1 reply

    Aegis_KleaisAuthorCorrect answer
    Inspiring
    August 12, 2012

    Nevermind, I guess I can just use XPath.