I have one XML file and I have created on function for retrieving value from XML nodes. Now the problem is if my node have no inner node, still flow goes inside the recursive sentence !
Have a look in my function
/*
XmlDocument x = new XmlDocument(); x.Load(filename);
*/
public string getValue(string nodename)
{
if (File.Exists(filename))
{
foreach (XmlNode xx in x.SelectNodes("//"+nodename))
{
if (xx.HasChildNodes)
getValue(nodename + "//"+xx.ChildNodes[0].Name);
else
return xx.InnerText;
}
}
return null;
}
My xmlfile is
<oodle_response stat="ok">
<current>
<region>
<id>barrie</id>
<name>Barrie</name>
</region>
<start>1</start>
<num>10</num>
</current>
</oodle_response>
and I am calling my function through
protected void btnLets_Click(object sender, EventArgs e)
{
string filename = Server.MapPath("~/xmls/newXmlFile.xml";
oodleXmlParser ox = new oodleXmlParser(filename);
Response.Write(ox.getValue("oodle_response"));
}