public static XPathDocument InputAs <TIn>(TIn input) { if (input == null) { return(null); } if (typeof(TIn).Equals(typeof(string))) { string s = input as string; s = HtmlUtility.ConvertToXml(s); s = LatinGlyphs.Condense(s); return(XmlUtility.GetNavigableDocument(s)); } else if (typeof(TIn).Equals(typeof(XmlDocument))) { return(XmlUtility.GetNavigableDocument(input as XmlDocument)); } else if (typeof(TIn).Equals(typeof(XPathDocument))) { return(input as XPathDocument); } else { return(null); } }
/// <summary> /// Expands selected Latin glyphs /// into their decimal entity equivalent. /// </summary> /// <param name="glyphText"> /// The <see cref="System.String"/> /// containing the glyphs. /// </param> /// <returns> /// Returns a <see cref="System.String"/> /// with decimal entities. /// </returns> public static string Expand(string glyphText) { if (_glyphs.Count == 0) { LatinGlyphs.AddGlyphs(); } foreach (string s in _glyphs.Keys) { glyphText = glyphText.Replace(s, _glyphs[s]); } return(glyphText); }
/// <summary> /// Condenses selected decimal entities /// into their Latin glyph equivalent. /// </summary> /// <param name="entityText"> /// The <see cref="System.String"/> /// containing the decimal entities. /// </param> /// <returns> /// Returns a <see cref="System.String"/> /// with Latin glyphs. /// </returns> public static string Condense(string entityText) { if (_glyphs.Count == 0) { LatinGlyphs.AddGlyphs(); } foreach (string s in _glyphs.Keys) { entityText = entityText.Replace(_glyphs[s], s); } //Search for selected named entities: entityText = entityText.Replace("©", "©"); entityText = entityText.Replace("é", "é"); entityText = entityText.Replace(" ", " "); entityText = entityText.Replace("®", "®"); entityText = entityText.Replace("™", "™"); return(entityText); }