public void SubscriptionUpdateReceived(UserModel userModel, string update)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(update);
            XmlNamespaceManager nsMgr = new XmlNamespaceManager(doc.NameTable);

            nsMgr.AddNamespace("atom", "http://www.w3.org/2005/Atom");
            var extractor = new XPathValueExtractorService(doc, nsMgr, _loggingService);

            string feedUpdated    = extractor.TryGetValue("//atom:feed/atom:updated/text()");
            string entryPublished = extractor.TryGetValue("//atom:feed/atom:entry/atom:published/text()");
            string entryId        = extractor.TryGetValue("//atom:feed/atom:entry/atom:id/text()");
            string entryTitle     = extractor.TryGetValue("//atom:feed/atom:entry/atom:title/text()");
            string entryContent   = extractor.TryGetValue("//atom:feed/atom:entry/atom:content/text()");

            entryContent = Regex.Replace(entryContent, @"((<[\s\/]*script\b[^>]*>)([^>]*)(<\/script>))", "", RegexOptions.IgnoreCase | RegexOptions.Multiline);
            if (entryContent.Length > 25000)
            {
                entryContent = entryContent.Substring(0, Config.TrimEntryContentLength);

                _loggingService.Warn("Trimming message content for \"" + entryTitle + "\" due to large content size");
            }

            string entryAuthors     = extractor.TryGetList("//atom:feed/atom:entry/atom:author/atom:name/text()");
            string entryLinkAlt     = extractor.TryGetValue("//atom:feed/atom:entry/atom:link[@rel='alternate']/@href");
            string entryLinkReplies = extractor.TryGetValue("//atom:feed/atom:entry/atom:link[@rel='replies']/@href");


            var publishMessage = new PublishMessage(userModel.PushTopic);

            publishMessage.Values.Add("feedUpdated", feedUpdated);
            publishMessage.Values.Add("entryPublished", entryPublished);
            publishMessage.Values.Add("entryId", entryId);
            publishMessage.Values.Add("entryTitle", entryTitle);
            publishMessage.Values.Add("entryContent", entryContent);
            publishMessage.Values.Add("entryAuthors", entryAuthors);
            publishMessage.Values.Add("entryLinkAlternate", entryLinkAlt);
            publishMessage.Values.Add("entryLinkReplies", entryLinkReplies);

            _queueWriter.Write(publishMessage);
        }
        public void SubscriptionUpdateReceived(UserModel userModel, string update)
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(update);
            XmlNamespaceManager nsMgr = new XmlNamespaceManager(doc.NameTable);
            nsMgr.AddNamespace("atom", "http://www.w3.org/2005/Atom");
            var extractor = new XPathValueExtractorService(doc, nsMgr, _loggingService);

            string feedUpdated = extractor.TryGetValue("//atom:feed/atom:updated/text()");
            string entryPublished = extractor.TryGetValue("//atom:feed/atom:entry/atom:published/text()");
            string entryId = extractor.TryGetValue("//atom:feed/atom:entry/atom:id/text()");
            string entryTitle = extractor.TryGetValue("//atom:feed/atom:entry/atom:title/text()");
            string entryContent = extractor.TryGetValue("//atom:feed/atom:entry/atom:content/text()");
            entryContent = Regex.Replace(entryContent, @"((<[\s\/]*script\b[^>]*>)([^>]*)(<\/script>))", "", RegexOptions.IgnoreCase | RegexOptions.Multiline);
            if (entryContent.Length > 25000)
            {
                entryContent = entryContent.Substring(0, Config.TrimEntryContentLength);

                _loggingService.Warn("Trimming message content for \"" + entryTitle + "\" due to large content size");
            }

            string entryAuthors = extractor.TryGetList("//atom:feed/atom:entry/atom:author/atom:name/text()");
            string entryLinkAlt = extractor.TryGetValue("//atom:feed/atom:entry/atom:link[@rel='alternate']/@href");
            string entryLinkReplies = extractor.TryGetValue("//atom:feed/atom:entry/atom:link[@rel='replies']/@href");


            var publishMessage = new PublishMessage(userModel.PushTopic);
            publishMessage.Values.Add("feedUpdated", feedUpdated);
            publishMessage.Values.Add("entryPublished", entryPublished);
            publishMessage.Values.Add("entryId", entryId);
            publishMessage.Values.Add("entryTitle", entryTitle);
            publishMessage.Values.Add("entryContent", entryContent);
            publishMessage.Values.Add("entryAuthors", entryAuthors);
            publishMessage.Values.Add("entryLinkAlternate", entryLinkAlt);
            publishMessage.Values.Add("entryLinkReplies", entryLinkReplies);

            _queueWriter.Write(publishMessage);
        }
        public void XPathValueExtractorServiceConstructorTest()
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<?xml version=\"1.0\"?> " +
                        "<feed xmlns:geo=\"http://www.georss.org/georss\" xmlns=\"http://www.w3.org/2005/Atom\" xmlns:as=\"http://activitystrea.ms/spec/1.0/\" xmlns:sf=\"http://superfeedr.com/xmpp-pubsub-ext\">" +
                        "   <updated>2010-07-01T02:04:42+00:00</updated>" +
                        "   <id>http://superfeedr.com/track/real-time-push</id>" +
                        "   <title></title>" +
                        "   <link type=\"application/atom+xml\" rel=\"self\" href=\"http://superfeedr.com/track/real-time-push\"/>" +
                        "   <entry xml:lang=\"en-US\">" +
                        "       <id>tag:typepad.com,2003:post-6a00e551f19dba883301348085952c970c</id>" +
                        "       <published>2010-05-07T02:56:46+00:00</published>" +
                        "       <title>Polling across the Pond</title>" +
                        "       <content type=\"html\">Some content</content>" +
                        "       <link title=\"Polling across the Pond\" type=\"text/html\" rel=\"alternate\" href=\"http://dcdiary.typepad.com/home/2010/05/polling-across-the-pond.html\"/>" +
                        "       <link title=\"Polling across the Pond\" type=\"text/html\" rel=\"replies\" href=\"http://dcdiary.typepad.com/home/2010/05/polling-across-the-pond.html\"/>" +
                        "       <category term=\"Current Affairs\"/>" +
                        "       <author>" +
                        "           <name>Emma Shercliff</name>" +
                        "           <uri/>" +
                        "           <email/>" +
                        "       </author>" +
                        "   </entry>" +
                        "</feed>");
            XmlNamespaceManager nsMgr = new XmlNamespaceManager(doc.NameTable);
            nsMgr.AddNamespace("atom", "http://www.w3.org/2005/Atom");
            var extractor = new XPathValueExtractorService(doc, nsMgr, _loggingService);

            string feedUpdated = extractor.TryGetValue("//atom:feed/atom:updated/text()");
            string entryPublished = extractor.TryGetValue("//atom:feed/atom:entry/atom:published/text()");
            string entryId = extractor.TryGetValue("//atom:feed/atom:entry/atom:id/text()");
            string entryTitle = extractor.TryGetValue("//atom:feed/atom:entry/atom:title/text()");
            string entryContent = extractor.TryGetValue("//atom:feed/atom:entry/atom:content/text()");
            string entryAuthors = extractor.TryGetList("//atom:feed/atom:entry/atom:author/atom:name/text()");
            string entryLinkAlt = extractor.TryGetValue("//atom:feed/atom:entry/atom:link[@rel='alternate']/@href");
            string entryLinkReplies = extractor.TryGetValue("//atom:feed/atom:entry/atom:link[@rel='replies']/@href");
        }