/// <summary> /// Reads raw Xml and grabs the <text> node's inner text. /// </summary> /// <param name="rawXml">The Xml to be parsed. /// It should follow the lipsum.dtd but really all it needs /// a text node as a child of the document element. /// (<root><text>your lipsum text</text></root> /// </param> /// <returns></returns> public static StringBuilder GetTextFromRawXml(string rawXml) { StringBuilder text = new StringBuilder(); XmlDocument data = LipsumUtilities.LoadXmlDocument(rawXml); XmlNode textNode = data.DocumentElement.SelectSingleNode("text"); if (textNode != null) { text.Append(textNode.InnerText); } return(text); }
/// <summary> /// Reads raw Xml and grabs the <text> node's inner text. /// </summary> /// <param name="rawXml">The Xml to be parsed. /// It should follow the lipsum.dtd but really all it needs /// a text node as a child of the document element. /// (<root><text>your lipsum text</text></root> /// </param> /// <returns></returns> public static StringBuilder GetTextFromRawXml(string rawXml) { StringBuilder text = new StringBuilder(); #if PORTABLE XDocument data = LipsumUtilities.LoadXmlDocument(rawXml); XElement textNode = data.Root.Element("text"); if (textNode != null) { text.Append(textNode.Value); } #else XmlDocument data = LipsumUtilities.LoadXmlDocument(rawXml); XmlNode textNode = data.DocumentElement.SelectSingleNode("text"); if (textNode != null) { text.Append(textNode.InnerText); } #endif return(text); }