0

http://lankacnews.com/sinhala/feed/

this is a feed address of a news web site. It contains 11 latest news. I want to get those news from that rss feed and show them on my program. It contains news like this.

http://i44.tinypic.com/a3cxsw.png

between content : encoded tag.

I want to get it and show it in my application. This is the code I have used..

XmlDocument lkcnws = new XmlDocument();
        lkcnws.Load(@"http://lankacnews.com/sinhala/feed/");

        textBox1.Text = lkcnws.OuterXml;

        XmlNodeList ndlst;
        XmlNode root = lkcnws.DocumentElement;

        ndlst = root.SelectNodes("//p");

        foreach (XmlNode nd in ndlst)
        {
            textBox2.Text += nd.OuterXml;
        }

but it does not work. Whats the wrong with this code and how can I solve this ?

2
  • do you get some exception? it does not work means a lot of things.
    – Ehsan
    Dec 14, 2013 at 6:57
  • +No One No I didnt get any exception
    – Gmnd-i
    Dec 14, 2013 at 7:02

1 Answer 1

0

Try this:

 void test() {
            XmlDocument lkcnws = new XmlDocument();

            lkcnws.Load("http://lankacnews.com/sinhala/feed/");

            textBox1.Text = lkcnws.OuterXml;

            XmlNodeList ndlst = lkcnws.SelectNodes("//category['@*']"); // it's null with p

            foreach (XmlNode nd in ndlst)
            {
                textBox2.Text += nd.InnerXml;
            }
        }
10
  • Error 1 Cannot implicitly convert type 'System.Xml.XmlNode' to 'System.Xml.XmlNodeList' C:\Users\Astro\documents\visual studio 2010\Projects\Lankadeepa\Lankadeepa\Form1.cs 54 25 Lankadeepa
    – Gmnd-i
    Dec 14, 2013 at 7:10
  • :D Now I have to create a project and test your solution
    – Ringo
    Dec 14, 2013 at 7:30
  • I tried to get category node instead of <p>. It's working fine, but I don't understand it's null with <p>.
    – Ringo
    Dec 14, 2013 at 8:14
  • excuse me ? I dont get what you said .
    – Gmnd-i
    Dec 14, 2013 at 14:44
  • Sorry for my English! I mean my code is working fine with "category" node. But it return null with "p" node. So make sure node "p" is exist. you see?
    – Ringo
    Dec 14, 2013 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.