return NS_ERROR_FAILURE;
return NS_OK;
nsFeedLoadListener::TryParseAsSimpleRSS (){    nsresult rv;    nsCOMPtr<nsIDOMParser> parser(do_CreateInstance("@mozilla.org/xmlextras/domparser;1", &rv));    if (NS_FAILED(rv)) return rv;    nsCOMPtr<nsIDOMDocument> xmldoc;    rv = parser->ParseFromBuffer ((const PRUint8*) mBody.get(), mBody.Length(), "text/xml", getter_AddRefs(xmldoc));    if (NS_FAILED(rv)) return rv;    // becomes true if we figure out that this is an atom stream.    PRBool isAtom = PR_FALSE;    nsCOMPtr<nsIDOMElement> docElement;    rv = xmldoc->GetDocumentElement(getter_AddRefs(docElement));    if (!docElement) return NS_ERROR_UNEXPECTED;    if (NS_FAILED(rv)) return rv;    nsCOMPtr<nsIDOMNode> node;    rv = xmldoc->GetFirstChild(getter_AddRefs(node));    if (!node) return NS_ERROR_UNEXPECTED;    if (NS_FAILED(rv)) return rv;    PRBool lookingForChannel = PR_FALSE;    while (node) {        PRUint16 ntype;        rv = node->GetNodeType(&ntype);        if (NS_FAILED(rv)) return rv;        if (ntype == nsIDOMNode::ELEMENT_NODE) {            nsAutoString nname;            rv = node->GetNodeName (nname);            /* slight hack to get node pointing to the thing that             * has items/entries as its children.  We need to descend             * into <channel> for RSS, but not for Atom.             */            if (!lookingForChannel) {                if (nname.Equals(NS_LITERAL_STRING("rss"))) {                    lookingForChannel = PR_TRUE;                    nsCOMPtr<nsIDOMNode> temp;                    rv = node->GetFirstChild(getter_AddRefs(temp));                    if (!temp) return NS_ERROR_UNEXPECTED;                    if (NS_FAILED(rv)) return rv;                    node = temp;                    continue;                }                if (nname.Equals(NS_LITERAL_STRING("feed"))) {                    /* Atom has no <channel>; instead, <item>s are                     * children of <feed> */                    isAtom = PR_TRUE;                    break;                }            } else {                if (nname.Equals(NS_LITERAL_STRING("channel"))) {                    break;                }            }        }        nsCOMPtr<nsIDOMNode> temp;        rv = node->GetNextSibling(getter_AddRefs(temp));        if (!temp) return NS_ERROR_UNEXPECTED;        if (NS_FAILED(rv)) return rv;        node = temp;    }    // we didn't find a rss/feed/channel or whatever    if (!node)        return NS_ERROR_FAILURE;    nsCOMPtr<nsIDOMElement> chElement = do_QueryInterface(node);    if (!chElement) return NS_ERROR_UNEXPECTED;    /* Go through the <channel>/<feed> and do what we need     * with <item> or <entry> nodes     */    int numMarksAdded = 0;    rv = chElement->GetFirstChild(getter_AddRefs(node));    if (!node) return NS_ERROR_UNEXPECTED;    if (NS_FAILED(rv)) return rv;    while (node) {        PRUint16 ntype;        rv = node->GetNodeType(&ntype);        if (NS_FAILED(rv)) return rv;        if (ntype == nsIDOMNode::ELEMENT_NODE) {            nsAutoString nname;            rv = node->GetNodeName (nname);            if ((!isAtom && nname.Equals(NS_LITERAL_STRING("item"))) ||                ( isAtom && nname.Equals(NS_LITERAL_STRING("entry"))))            {                /* We need to pull out the <title> and <link> children */                nsAutoString titleStr;                nsAutoString linkStr;                nsAutoString dateStr;                nsCOMPtr<nsIDOMNode> childNode;                rv = node->GetFirstChild(getter_AddRefs(childNode));                if (NS_FAILED(rv)) return rv;                while (childNode) {                    PRUint16 childNtype;                    rv = childNode->GetNodeType(&childNtype);                    if (NS_FAILED(rv)) return rv;                    if (childNtype == nsIDOMNode::ELEMENT_NODE) {                        nsAutoString childNname;                        rv = childNode->GetNodeName (childNname);                        if (childNname.Equals(NS_LITERAL_STRING("title"))) {                            rv = FindTextInNode (childNode, titleStr);                            if (NS_FAILED(rv)) break;                        } else if (childNname.Equals(NS_LITERAL_STRING("pubDate")) ||                                   childNname.Equals(NS_LITERAL_STRING("updated")))                        {                            rv = FindTextInNode (childNode, dateStr);                            if (NS_FAILED(rv)) break;                        } else if (!isAtom && childNname.Equals(NS_LITERAL_STRING("guid"))) {                            nsCOMPtr<nsIDOMElement> linkElem = do_QueryInterface(childNode);                            if (!linkElem) break; // out of while(childNode) loop                                                        nsAutoString isPermaLink;                            linkElem->GetAttribute(NS_LITERAL_STRING("isPermaLink"), isPermaLink);                            // Ignore failures. isPermaLink defaults to true.                            if (!isPermaLink.Equals(NS_LITERAL_STRING("false"))) {                                // in node's TEXT                                rv = FindTextInNode (childNode, linkStr);                                if (NS_FAILED(rv)) break;                            }                        } else if (childNname.Equals(NS_LITERAL_STRING("link"))) {                            if (isAtom) {                                 // in HREF attribute                                nsCOMPtr<nsIDOMElement> linkElem = do_QueryInterface(childNode);                                if (!linkElem) break; // out of while(childNode) loop                                nsAutoString rel;                                linkElem->GetAttribute(NS_LITERAL_STRING("rel"), rel);                                if (rel.Equals(NS_LITERAL_STRING("alternate")) ||                                    rel.IsEmpty())                                {                                    rv = linkElem->GetAttribute(NS_LITERAL_STRING("href"), linkStr);                                    if (NS_FAILED(rv)) break; // out of while(childNode) loop                                }                            } else if (linkStr.IsEmpty()) {                                // in node's TEXT                                rv = FindTextInNode (childNode, linkStr);                                if (NS_FAILED(rv)) break;                            }                        }                    }                    if (!titleStr.IsEmpty() && !linkStr.IsEmpty())                        break;                    nsCOMPtr<nsIDOMNode> temp;                    rv = childNode->GetNextSibling(getter_AddRefs(temp));                    childNode = temp;                    if (!childNode || NS_FAILED(rv)) break;                }                if (titleStr.IsEmpty() && !dateStr.IsEmpty())                    titleStr.Assign(dateStr);                if (!titleStr.IsEmpty() && !linkStr.IsEmpty() && IsLinkValid(linkStr.get())) {                    nsCOMPtr<nsIRDFResource> newBM;                    rv = mBMSVC->CreateBookmark (titleStr.get(), linkStr.get(),                                                 nsnull, nsnull, nsnull, nsnull,                                                 getter_AddRefs(newBM));                    if (NS_FAILED(rv)) return rv;                    rv = mLivemarkContainer->AppendElement(newBM);                    if (NS_FAILED(rv)) return rv;                    numMarksAdded++;                }            }        }        nsCOMPtr<nsIDOMNode> temp;        rv = node->GetNextSibling(getter_AddRefs(temp));        if (NS_FAILED(rv)) return rv;        node = temp;    }    if (numMarksAdded > 0) {#ifdef DEBUG_vladimir        NS_WARNING (">>>> Success from TryParseAsSimpleRSS!\n");#endif        return NS_OK;    }    return NS_ERROR_FAILURE;}