erminas.SmartAPI.Utils.XmlUtil.GetSingleElement C# (CSharp) Method

GetSingleElement() public static method

public static GetSingleElement ( this doc, string tagName ) : XmlElement
doc this
tagName string
return System.Xml.XmlElement
        public static XmlElement GetSingleElement(this XmlDocument doc, string tagName)
        {
            var nodes = doc.GetElementsByTagName(tagName);
            if (nodes.Count != 1)
            {
                throw new SmartAPIInternalException(
                    string.Format("Invalid number of {0} elements in XML reply from server. Expected: 1 actual: {1}",
                                  tagName, nodes.Count));
            }

            return (XmlElement) nodes[0];
        }