Read XML data from Web URL using C#

Today i had faced one scenario, Read XML value from web url and display it in a SharePoint WebPart (Stock Details)

i used the below code

XmlDocument document = new XmlDocument();
document.Load("http://www.url.com/1.php");
XmlElement root = document.DocumentElement;
XmlNodeList nodes = root.ChildNodes; //.SelectNodes("/nodeName");
foreach (XmlNode node in nodes)
{
       XmlNodeList nodes2 = root.SelectNodes("/"+root.Name+"/" + node.Name);
       foreach (XmlNode nodex in nodes2)
       {
           string value = nodex["node_name"].InnerText;
       }

}


Its working. Hope this will helps u.....

Comments

Popular posts from this blog

IRM and the Object Model

This content database has a schema version which is not supported in this farm

Activate and Deactivate Feature through PowerShell