Re: DOM - parse HTML document

From: Date: Tue, 12 Sep 2006 09:41:15 +0000
Subject: Re: DOM - parse HTML document
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-241653@lists.php.net to get a copy of this message
----- Original Message ----- From: "Leonidas Safran" <Elektrik@gmx.net>
By the way, because I found it strange to have more than one field with the same id, I looked on the famous selfhtml tutorial website http://de.selfhtml.org which says that unique id is only mandatory for css, but not for javascript actually. I was surprised... http://de.selfhtml.org/css/formate/zentrale.htm#individualformate http://en.selfhtml.org/css/formate/zentrale.htm#individualformate (english translation is a little different)
That is correct but it is not complete. Everything that relies on a unique id would fail, CSS amongst others(which is what this article covers), but not the only one. Basically there are two functions to get elements by id or name: getElementById and getElementsByName. Notice the first one returns a single element since there cannot be more than one, the second one returns a collection of elements, since duplicates are allowed. Thus, if you put an id in an element, it is because you want to reach it, but if the id is duplicated then you cannot reach it any longer. Satyam

« previous php.general (#241653) next »