Problem solve Get help with specific problems with your technologies, process and projects.

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?
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 last published in March 2002

Dig Deeper on Development implications of microservices architecture

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.