D
Doug
Hi
I have a method that I would like to return the value to the calling event.
I have a bad example below that doesnt give me what I want.
What I want is to have a my readxml mthod return the value of a string in an
xml file if that element is in the xml file - but a message saying that the
string doesnt exist if it is not there.
I have used a method that should return a string, but it doesn't work- even
though the string is in the xml file. I often get an error that not all
code paths return a value. If you can fix my code to avoid this error
please help.
public string readxml()
{
XmlTextReader tr = null;
tr = new XmlTextReader(xmlFilename);
while (tr.Read())
{
if (tr.NodeType == XmlNodeType.Element)
{
if (tr.LocalName.Equals("location"))
{
return tr.ReadString();
}
}
else
{
return "Nothing here";
}
tr.Close();
}
}
thanks for you assistance
Doug
I have a method that I would like to return the value to the calling event.
I have a bad example below that doesnt give me what I want.
What I want is to have a my readxml mthod return the value of a string in an
xml file if that element is in the xml file - but a message saying that the
string doesnt exist if it is not there.
I have used a method that should return a string, but it doesn't work- even
though the string is in the xml file. I often get an error that not all
code paths return a value. If you can fix my code to avoid this error
please help.
public string readxml()
{
XmlTextReader tr = null;
tr = new XmlTextReader(xmlFilename);
while (tr.Read())
{
if (tr.NodeType == XmlNodeType.Element)
{
if (tr.LocalName.Equals("location"))
{
return tr.ReadString();
}
}
else
{
return "Nothing here";
}
tr.Close();
}
}
thanks for you assistance
Doug