How do I get at the value of the "level" attribute?

How do I get at the value of the "level" attribute?

I am using JavaScript to display search results from an XML file to an HTML file (using .innerHTML). I have no problem accessing any element I want, but I cannot seem to get at the attributes (e.g., <objective level="1"> content here</objective>). How do I get at the value of the "level" attribute?

    Requires Free Membership to View

    When you register, you'll begin receiving targeted emails from my team of award-winning writers. Our goal is to keep you informed on recent service-oriented architecture (SOA) and SOA-related topics such as integration, governance, Web services, Cloud and more.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchSOA.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSOA.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

innerHTML will return a string. This string can be used to create a DOM. From there, the methods to access elements and attributes are per the DOM specifications. In particular, if you have an Element object you can use the getAttribute() method to retrieve an attribute value.

This was first published in March 2002