/// <summary> /// Get Data From current XmlAttribute /// </summary> public static string G(this XmlAttribute CurrElement, Xv ValueType = Xv.V) { if (CurrElement == null) { return(null); } return(ValueType == Xv.T ? CurrElement.InnerText : ValueType == Xv.X ? CurrElement.InnerXml : ValueType == Xv.O ? CurrElement.OuterXml : CurrElement.Value); }
/// <summary> /// Get Attributes Data From Xml Element with current ElementPath and optional TheseAttributesOnly (or all) /// </summary> public static IDictionary <string, string> G(this XmlDocument CurrDoc, string ElementPath, Xv ValueType = Xv.V, IEnumerable <string> TheseAttributesOnly = null) { if (CurrDoc == null) { return(null); } var r = CurrDoc.DocumentElement[ElementPath]; if (r == null || r.Attributes == null || r.Attributes.Count < 0) { return(null); } var a = new Dictionary <string, string>(); foreach (XmlAttribute item in r.Attributes) { if (TheseAttributesOnly == null || TheseAttributesOnly.Contains(item.Name)) { a.Add(item.Name, item.G(ValueType)); } } return(a); }
/// <summary> /// Get Data From Xml Element with current ElementPath and AttributePath /// </summary> public static string G(this XmlDocument CurrDoc, string ElementPath, string AttributePath = null, Xv ValueType = Xv.V) { if (CurrDoc == null) { return(null); } var r = CurrDoc.DocumentElement[ElementPath]; if (r == null) { return(null); } if (!AttributePath.C() || !r.HasAttribute(AttributePath)) { return(r.G(ValueType)); } var a = r.Attributes[AttributePath]; if (a == null) { return(null); } return(a.G(ValueType)); }