SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reading attributes dinamically

    Hi! I would like a help reading a tag attribute, without knowing the attribute name. I know I can use element.getAttribute('attributeName'); to read an attribute, but I would like to read an attribute from a xml tag without knowing the name. I appreciate any help.

  2. #2
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can get a node list of an element's attributes with
    element.attributes , and loop through them.

    If the element has only one attribute it will be element.attributes[0];
    you can query the element.attributes[0].name and
    element.attributes[0].value.

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, it works.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •