I'm trying to determine if XML node attribute exists. Here is my code:
var xmlNode = element.Attributes("parent");
if (xmlNode != null) // Expression is always true
{
var parentNodeId = element.Attribute("parent").Value;
if (groupables.ContainsKey(parentNodeId))
{
parent = groupables[parentNodeId];
}
}
ReSharper is telling me that the line where I check if xmlNode is null will always be true. Why is that? I am parsing an XML file, some of the nodes contain "parent" as an attribute. Some do not. So why does ReSharper think otherwise?