public static string ExtractContent(this XPathNavigator node) { if (node == null) { return((string)null); } return(XmlTextHelper.NormalizeIndentation(XPathNavigatorExtensions.ConstPattern.Replace(XPathNavigatorExtensions.ParamPattern.Replace(node.InnerXml, new MatchEvaluator(XPathNavigatorExtensions.GetParamRefName)), new MatchEvaluator(XPathNavigatorExtensions.GetConstRefName)))); }
public static string ExtractContent(this XPathNavigator node) { if (node == null) { return(null); } return(XmlTextHelper.NormalizeIndentation( ConstPattern.Replace( ParamPattern.Replace(node.InnerXml, GetParamRefName), GetConstRefName) )); }
public static string NormalizeIndentation(string xmlText) { if (xmlText == null) { throw new ArgumentNullException(nameof(xmlText)); } string[] lines = xmlText.Split('\n'); string leadingWhitespace = XmlTextHelper.GetCommonLeadingWhitespace(lines); int num = leadingWhitespace == null ? 0 : leadingWhitespace.Length; int index = 0; for (int length = lines.Length; index < length; ++index) { string str = lines[index].TrimEnd('\r'); if (num != 0 && str.Length >= num && str.Substring(0, num) == leadingWhitespace) { str = str.Substring(num); } lines[index] = str; } return(string.Join("\r\n", ((IEnumerable <string>)lines).SkipWhile <string>((Func <string, bool>)(x => string.IsNullOrWhiteSpace(x)))).TrimEnd()); }