csharp xml check if attribute exists

Code Example - csharp xml check if attribute exists

                
                        static IEnumerable<(string key, string value)> GetNodeAttributes(XmlReader reader)
{
    for (int i = 0; i < reader.AttributeCount; i++)
    {
        reader.MoveToAttribute(i);
        yield return (reader.Name, reader.Value);
    }
}