photography by Kristel van Beek
posted by: martijn, at 27 September 2007 11:46 GMT+1, 7 January 2008 22:03 GMT+1
Testing the result as a string wouldn't help because the attribute is of the type XML.
My solution is not elegant but it works (I'm hoping someone can tell me a better solution).
if ( node.@test != node.@nonexistingattribute ) {
// attribute exists
}
As you can see I compare the attribute with an attribute I definitely know is not present.
Update: The technique given by Mathis is working like a charm, thanks!
Update 2: My apologise, the method Mathis has given doesn't work. The one I found working is:
if ("@attr" in node) { ... }
Thanks Valery Silaev
Eric-Paul says:
at 4 December, 2007 11:12 www.lostboys.nl