nsCOMPtr<nsIDOMNode> firstChild, child2; nsresult rv = mOptGroup->GetFirstChild(getter_AddRefs(firstChild)); NS_ENSURE_SUCCESS(rv, rv);  nsAutoString value;  if (firstChild) { firstChild->GetLocalName(value); if (!value.EqualsLiteral("option")) { mOptGroup->RemoveChild(firstChild, getter_AddRefs(child2)); mOptGroup->GetFirstChild(getter_AddRefs(firstChild)); } }     nsCOMPtr<nsIDOMNodeList> children; rv = mElement->GetChildNodes(getter_AddRefs(children)); NS_ENSURE_SUCCESS(rv, rv);  PRUint32 childCount; children->GetLength(&childCount);  nsCOMPtr<nsIDOMNode> child; nsAutoString labelValue;  for (PRUint32 i = 0; i < childCount; ++i) { children->Item(i, getter_AddRefs(child)); if (nsXFormsUtils::IsLabelElement(child)) {  child->CloneNode(PR_TRUE, getter_AddRefs(child2)); mOptGroup->InsertBefore(child2, firstChild, getter_AddRefs(child)); } }  return NS_OK;
nsXFormsChoicesElement::Refresh(){  if (mInsideSelect1) {    // <select1> is XBLized, so there is no need to recreate UI -    // XBL will do it for us.    return NS_OK;  }  // Remove any existing first child that is not an option, to clear out  // any existing label.  nsCOMPtr<nsIDOMNode> firstChild, child2;  nsresult rv = mOptGroup->GetFirstChild(getter_AddRefs(firstChild));  NS_ENSURE_SUCCESS(rv, rv);  nsAutoString value;  if (firstChild) {    firstChild->GetLocalName(value);    if (!value.EqualsLiteral("option")) {      mOptGroup->RemoveChild(firstChild, getter_AddRefs(child2));      mOptGroup->GetFirstChild(getter_AddRefs(firstChild));    }  }  // We need to find our label element and clone it into the optgroup.  // This content will appear before any of the optgroup's options.  nsCOMPtr<nsIDOMNodeList> children;  rv = mElement->GetChildNodes(getter_AddRefs(children));  NS_ENSURE_SUCCESS(rv, rv);  PRUint32 childCount;  children->GetLength(&childCount);  nsCOMPtr<nsIDOMNode> child;  nsAutoString labelValue;  for (PRUint32 i = 0; i < childCount; ++i) {    children->Item(i, getter_AddRefs(child));    if (nsXFormsUtils::IsLabelElement(child)) {      // Clone our label into the optgroup      child->CloneNode(PR_TRUE, getter_AddRefs(child2));      mOptGroup->InsertBefore(child2, firstChild, getter_AddRefs(child));    }  }  return NS_OK;}