/// <summary> /// Determine whether the object's XML contains the specified position. /// </summary> /// <param name="position"> /// The target position. /// </param> /// <returns> /// <c>true</c>, if the the specified position lies within the object's XML span; otherwise, <c>false</c>. /// </returns> public bool XmlContains(Position position) { if (position == null) { throw new ArgumentNullException(nameof(position)); } return(XmlRange.Contains(position)); }
public static XmlElement GetFirstXmlElement(XmlDocument xDoc, string name, string attribute, string value, XmlRange range) { string xPath = GetXPath(name, attribute, value, range); return(GetFirstXmlElement(xDoc, xPath)); }
public static XmlNodeList GetXmlNodeList(XmlDocument xDoc, string name, XmlRange range) { string xPath = GetXPath(name, null, null, range); return(GetXmlNodeList(xDoc, xPath)); }
public static IEnumerable <XElement> GetXElement(XDocument xDoc, string name, string attribute, string value, XmlRange range) { string xPath = GetXPath(name, null, null, range); return(xDoc.Root.XPathSelectElements(xPath)); }
public static XmlElement GetFirstXmlElement(XmlElement xElement, string name, XmlRange range) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(xElement.OuterXml); return(GetFirstXmlElement(xmlDocument, name, range)); }
public static XElement GetFirstXElement(XDocument xDoc, string name, XmlRange range) { string xPath = GetXPath(name, null, null, range); return(xDoc.Root.XPathSelectElement(xPath)); }
public static IEnumerable <XElement> GetXElement(XElement xElement, string name, string attribute, string value, XmlRange range) { string xPath = GetXPath(name, null, null, range); return(GetXElement(xElement, xPath)); }
public static XElement GetFirstXElement(XElement xElement, string name, XmlRange range) { string xPath = GetXPath(name, null, null, range); return(GetFirstXElement(xElement, xPath)); }
public static string GetXPath(string xeName, string xeAttribute, string xeValue, XmlRange range) { string result = null; switch (range) { case XmlRange.All: result = ((xeAttribute == null || xeValue == null || !(xeAttribute.Trim() != "") || !(xeValue.Trim() != "")) ? ("//" + xeName) : $"//{xeName}[@{xeAttribute}=\"{xeValue}\"]"); break; case XmlRange.Root: result = ((xeAttribute == null || xeValue == null || !(xeAttribute.Trim() != "") || !(xeValue.Trim() != "")) ? ("/" + xeName) : $"/{xeName}[@{xeAttribute}=\"{xeValue}\"]"); break; case XmlRange.ThisNode: result = ((xeAttribute == null || xeValue == null || !(xeAttribute.Trim() != "") || !(xeValue.Trim() != "")) ? (xeName ?? "") : $"{xeName}[@{xeAttribute}=\"{xeValue}\"]"); break; } return(result); }
/// <summary> /// Determine whether the object's XML contains the specified position. /// </summary> /// <param name="position"> /// The target position. /// </param> /// <returns> /// <c>true</c>, if the specified position lies within the object's XML span; otherwise, <c>false</c>. /// </returns> public bool XmlContains(Position position) { return(XmlRange.Contains(position)); }