2 Replies Latest reply on Jul 2, 2009 2:36 AM by Thomas B. Nielsen

    Determine if JS XML element has an attribute of a given name

    Thomas B. Nielsen Level 3

      Hello scripters,

       

      Can anyone tell me how to test for the existance of a xml attribute in a JavaScript XML object?

       

      If i do:

       

      myXML = new XML(<pets><dogs><fido color="red"/><spike/></dogs></pets>);


      now check if i want to check if fido have a color attribute, what should i do?

       

      If i do alert(myXML.dogs.spike.color) it will just give me an empty string (XML), rather than fail