Skip navigation
Currently Being Moderated

How to reference a value in an XML file

Aug 10, 2012 12:50 PM

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?

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points