nsresult res = NS_ERROR_FAILURE; nsAutoString name, value; nsISupportsArray *attributes = nsnull; if (NS_OK == NS_NewISupportsArray(&attributes)) { PRInt32 count; mContent->GetAllAttributeNames(attributes, count); if (count > 0) { if ((PRInt32)aIndex < count) { nsISupports *att = attributes->ElementAt(aIndex); static NS_DEFINE_IID(kIAtom, NS_IATOM_IID); nsIAtom *atName = nsnull; if (nsnull != att && NS_OK == att->QueryInterface(kIAtom, (void**)&atName)) { atName->ToString(name); if (NS_CONTENT_ATTR_NOT_THERE != mContent->GetAttribute(name, value)) { *aReturn = (nsIDOMNode *)new DOMAttribute(name, value); res = NS_OK; } NS_RELEASE(atName); } }
if (mContent) { nsIContent *content = mContent->GetChildAt(aIndex); if (content) { return CallQueryInterface(content, aReturn);
DOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn){  nsresult res = NS_ERROR_FAILURE;  nsAutoString name, value;  nsISupportsArray *attributes = nsnull;  if (NS_OK == NS_NewISupportsArray(&attributes)) {    PRInt32 count;    mContent->GetAllAttributeNames(attributes, count);    if (count > 0) {      if ((PRInt32)aIndex < count) {        nsISupports *att = attributes->ElementAt(aIndex);        static NS_DEFINE_IID(kIAtom, NS_IATOM_IID);        nsIAtom *atName = nsnull;        if (nsnull != att && NS_OK == att->QueryInterface(kIAtom, (void**)&atName)) {          atName->ToString(name);          if (NS_CONTENT_ATTR_NOT_THERE != mContent->GetAttribute(name, value)) {            *aReturn = (nsIDOMNode *)new DOMAttribute(name, value);            res = NS_OK;          }          NS_RELEASE(atName);        }      }    }    NS_RELEASE(attributes);  }  return res;}