News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

Reading XML from web through C# code

Started by Kalyan, Apr 21, 2008, 04:13 PM

Previous topic - Next topic

Kalyan

Reading XML from web through C# code

Here is how you can grab the xml from a URL ( which points to an xml document such as RSS on the web )

For this you can use the XmlTextReader constructor that takes a URL as a parameter:

string url = "http://itacumens.com";

// use the XmlTextReader to get the xml at the url

XmlTextReader reader = new XmlTextReader (url);

   while (reader.Read( ))
   {
       switch (reader.NodeType)
       {
           case XmlNodeType.Element :
               Console.Write("<{0}>", reader.Name);
               break;
       }     
   }