Philip Grooms

Philip Grooms

  • NA
  • 39
  • 1.6k

Check if XML has a node

Jan 28 2023 11:12 PM

When reading an XML file into C# i can parse everything as long as the XML file has a Node/Element named Note. I need a way to read xml to see if Note exists and then do something else do something else. Any help would be greatly appreciated.

I have tried different code however they all have given me errors:

XmlNodeList elements = elmRoot.GetElementsByTagName("Node");
Boolean found = false;
foreach(XmlElement element in elements)
{
    if(element.Name  == Note)
    {
        found = true;
        break;
    }
}

 


Answers (3)