nsRDFDOMNodeList* elements; if (NS_FAILED(rv = nsRDFDOMNodeList::Create(&elements))) { NS_ERROR("unable to create node list");
nsCOMPtr<nsIDOMElement> element; element = do_QueryInterface(aNode); if (!element) return NS_OK;  if (aTagName.Equals("*")) { if (NS_FAILED(rv = aElements->AppendNode(aNode))) { NS_ERROR("unable to append element to node list"); return rv; } } else { nsAutoString name; if (NS_FAILED(rv = aNode->GetNodeName(name))) { NS_ERROR("unable to get node name"); return rv; }  if (aTagName.Equals(name)) { if (NS_FAILED(rv = aElements->AppendNode(aNode))) { NS_ERROR("unable to append element to node list"); return rv; } } }  nsCOMPtr<nsIDOMNodeList> children; if (NS_FAILED(rv = aNode->GetChildNodes( getter_AddRefs(children) ))) { NS_ERROR("unable to get node's children");
XULDocumentImpl::GetElementsByTagName(const nsString& aTagName, nsIDOMNodeList** aReturn){    nsresult rv;    nsRDFDOMNodeList* elements;    if (NS_FAILED(rv = nsRDFDOMNodeList::Create(&elements))) {        NS_ERROR("unable to create node list");        return rv;    }    nsIContent* root = GetRootContent();    NS_ASSERTION(root != nsnull, "no doc root");    if (root != nsnull) {        nsIDOMNode* domRoot;        if (NS_SUCCEEDED(rv = root->QueryInterface(nsIDOMNode::GetIID(), (void**) &domRoot))) {            rv = GetElementsByTagName(domRoot, aTagName, elements);            NS_RELEASE(domRoot);        }        NS_RELEASE(root);    }    *aReturn = elements;    return NS_OK;}