Novacode.DocX.getMarginAttribute C# (CSharp) Method

getMarginAttribute() private method

private getMarginAttribute ( System.Xml.Linq.XName name ) : float
name System.Xml.Linq.XName
return float
        internal float getMarginAttribute(XName name)
        {
            XElement body = mainDoc.Root.Element(XName.Get("body", w.NamespaceName));
            XElement sectPr = body.Element(XName.Get("sectPr", w.NamespaceName));
            XElement pgMar = sectPr?.Element(XName.Get("pgMar", w.NamespaceName));
            XAttribute top = pgMar?.Attribute(name);
            if (top != null)
            {
                float f;
                if (float.TryParse(top.Value, out f))
                    return (int)(f / 20.0f);
            }

            return 0;
        }