문제

VS2010을 사용하고 다른 사이트에서 RSS 콘텐츠를 읽고 내 사이트에 표시하고 현재이 프로세스는 수동으로 수행됩니다 (사이트 관리자는 다른 사이트를 검색하고 뉴스 항목의 관련 콘텐츠를 복사 / 페이스트합니다.).최상의 해결책이 RSS라고 생각하고, 나는 몇 가지 샘플 코드를 시도하지만, 그들 중 누구도 효과가 없었던 것들이 아프넷에서 RSS 리더를 구현하는 쉬운 방법이 있습니까?내 옵션은 무엇입니까?

도움이 되었습니까?

해결책

READ RSS 링크
public void ReadDoc(XmlDocument rssDoc)
{
    XmlNode nodeRss = null;
    XmlNode nodeChannel = null;
    XmlNode nodeItem = null;
    try
    {
        if (rssDoc == null)
        {
            return;
        }

        // Loop for the <rss> tag
        for (int i = 0; i < rssDoc.ChildNodes.Count; i++)
        {
            // If it is the rss tag
            if (rssDoc.ChildNodes[i].Name == "rss")
            {
                 nodeRss = rssDoc.ChildNodes[i];
                 break;
            }
        }

        if (nodeRss == null)
        {
            return;
        }
        for (int i = 0; i < nodeRss.ChildNodes.Count; i++)
        {
            if (nodeRss.ChildNodes[i].Name == "channel")
            {
                nodeChannel = nodeRss.ChildNodes[i];
                break;
            }
        }

        if (nodeChannel == null)
        {
            return;
        }

        // Loop for the <title>, <link>, <description> and all the other tags
        for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
        {
            if (nodeChannel.ChildNodes[i].Name == "item")
            {
                nodeItem = nodeChannel.ChildNodes[i];
                if (nodeItem["title"] != null){}
                if (nodeItem["description"] != null){}
                if (nodeItem["pubDate"] != null){}
            }
        }
    }
    catch (Exception)
    {
        throw;
    }
    finally
    {
        nodeRss = null;
        nodeChannel = null;
        nodeItem = null;
    }
}
.
public void CreateRSS(String Path)
{
    XmlDocument doc = null;
    XmlTextReader rssReader = null;
    Label doclbl = null;
    Label snolbl = null;
    try
    {
        try
        {
            rssReader = new XmlTextReader(Path);
        }
        catch (Exception)
        {
            return;
        }

        if (rssReader == null)
        {
            return;
        }

        doc = new XmlDocument();
        try
        {
            doc.Load(rssReader);
        }
        catch (Exception)
        {
            return;
        }

        if (doc == null)
        {
            return;
        }

        ReadDoc(doc);
    }
    catch (Exception)
    {
        throw;
    }
    finally
    {
        doc = null;
        rssReader = null;
        doclbl = null;
        snolbl = null;
    }
}
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top