I read tags for some information in the online dynamic xml file. But an error occurs if the tag I wanna read is not in the xml file. So, I wanna check the xml file. if the tag is in the xml file, start reading xml for the tag. if the tag is not in the xml file, not reading. I am not good in coding c#..
I use this method for reading xml file.
var xmldoc = new XmlDocument();
xmldoc.Load("http://yourwebsite.com/weather.xml");,
temperature.Text = xmldoc.SelectSingleNode("temp").InnerXml.ToString();
windspeed.Text = xmldoc.SelectSingleNode("wind_spd").InnerXml.ToString();
storm.Text = xmldoc.SelectSingleNode("storm").InnerXml.ToString();
The storm tag is sometimes to be in the xml file. Then I can read this time. But when the storm tag is not to be in xml file, I take an error. The code doesn't work.
Shortly, I wanna do this,
if(the storm tag is in xml) //check xml file.
{
storm.Text = xmldoc.SelectSingleNode("storm").InnerXml.ToString();
}
else
{
storm.text = "";
}