private static IEnumerable <XmlAttribute> GetAttributes(IXmlXPathNode node)
    {
        var xe = node as XmlElement;

        if (xe == null)
        {
            yield break;
        }
        foreach (XmlAttribute att in xe.Attributes)
        {
            yield return(att);
        }
    }
 private static XmlAttribute GetAttribute(IXmlXPathNode node, string name) => node is XmlElement xe ? xe.Attributes[name] : null;