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?
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
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.
Dig Deeper
-
People who read this also read...
This was first published in March 2002