• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to reference a value in an XML file

Enthusiast ,
Aug 10, 2012 Aug 10, 2012

Copy link to clipboard

Copied

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?

Views

394

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Aug 12, 2012 Aug 12, 2012

Nevermind, I guess I can just use XPath.

Votes

Translate

Translate
Enthusiast ,
Aug 12, 2012 Aug 12, 2012

Copy link to clipboard

Copied

LATEST

Nevermind, I guess I can just use XPath.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation