I've been working with xml lately. And have noticed a bit of a phenomenon (maybe not that big of a deal to the rest of the world, but to me it was). Perhaps, it is me being a newb. But shouldn't most hard coded or magic numbers be broken out to a configuration file? For example,
string url = "http://www.domain.com/aDocument.xml";
XmlDocument feed = new XmlDocument();
feed.Load(url);
XmlNode errorsNode = feed.SelectSingleNode("Errors");
if (errorsNode != null)
{
XmlNode error = errorsNode.FirstChild;
lblError.Text = "Error: " + error.SelectSingleNode("Code").InnerText;
}
Here is the xml document:
<Errors>
<Error>
<Code>AWS.MissingParameters</Code>
<Message>You are missing an parameter</Message>
</Error>
</Errors>
How would you parse this without hardcoding "code" or "message"?