Beispiel #1
0
        /// <summary>
        /// Reads raw Xml and grabs the &lt;text&gt; 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.
        /// (&lt;root&gt;&lt;text&gt;your lipsum text&lt;/text&gt;&lt;/root&gt;
        /// </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 &lt;text&gt; 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.
        /// (&lt;root&gt;&lt;text&gt;your lipsum text&lt;/text&gt;&lt;/root&gt;
        /// </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);
        }