XML to string (C#) -


i have xml loaded url this:

webclient client = new webclient(); client.encoding = encoding.utf8;  try {     string reply = client.downloadstring("http://example.com/somefile.xml");     label1.text = reply; } catch {     label1.text = "failed";  } 

that xml belongs rss feed. want label1.text shows titles of xml. how can achieve that?

example of label1.text

this first title    -    2nd title    -    , last title 

you can load xml xmldocument , use xpath value of each node you're targeting.

       xmldocument doc = new xmldocument();        doc.loadxml(reply);        xmlnodelist nodes = doc.selectnodes("//nodetoselect");         foreach (xmlnode node in nodes)        {            //if value want content of node            label1.text = node.innertext;             //if value want attribute of node            label1.text = node.attributes["attibutename"].value;         } 

if not familiar xpath can check here : http://www.w3schools.com/xpath/xpath_syntax.asp


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -