*aReturn = nsnull; for (PRUint32 i = 0; i < count && *aReturn == nsnull; i++) { nsIFormControl *control = (nsIFormControl*)mElements.ElementAt(i); if (nsnull != control) { nsIContent *content;  result = control->QueryInterface(kIContentIID, (void **)&content); if (NS_OK == result) { nsAutoString name;  if (((content->GetAttribute("NAME", name) == NS_CONTENT_ATTR_HAS_VALUE) && (aName.Equals(name))) || ((content->GetAttribute("ID", name) == NS_CONTENT_ATTR_HAS_VALUE) && (aName.Equals(name)))) { result = control->QueryInterface(kIDOMNodeIID, (void **)aReturn); } NS_RELEASE(content); } } }
nsFormControlList::NamedItem(const nsString& aName, nsIDOMNode** aReturn){  PRUint32 count = mElements.Count();  nsresult result = NS_OK;  *aReturn = nsnull;  for (PRUint32 i = 0; i < count && *aReturn == nsnull; i++) {    nsIFormControl *control = (nsIFormControl*)mElements.ElementAt(i);    if (nsnull != control) {      nsIContent *content;            result = control->QueryInterface(kIContentIID, (void **)&content);      if (NS_OK == result) {        nsAutoString name;        // XXX Should it be an EqualsIgnoreCase?        if (((content->GetAttribute("NAME", name) == NS_CONTENT_ATTR_HAS_VALUE) &&             (aName.Equals(name))) ||            ((content->GetAttribute("ID", name) == NS_CONTENT_ATTR_HAS_VALUE) &&             (aName.Equals(name)))) {          result = control->QueryInterface(kIDOMNodeIID, (void **)aReturn);        }        NS_RELEASE(content);      }    }  }    return result;}