当前位置: 首页>>代码示例>>C#>>正文


C# HtmlAgilityPack.CreateElement方法代码示例

本文整理汇总了C#中HtmlAgilityPack.CreateElement方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlAgilityPack.CreateElement方法的具体用法?C# HtmlAgilityPack.CreateElement怎么用?C# HtmlAgilityPack.CreateElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HtmlAgilityPack的用法示例。


在下文中一共展示了HtmlAgilityPack.CreateElement方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AnnotateWikiPost

        public bool AnnotateWikiPost(HtmlAgilityPack.XmlDocument xmlDoc)
        {
            try
            {
                var eventDataNode = xmlDoc.DocumentNode.SelectSingleNode("//ns1:eventData");
                var wikiNode = eventDataNode.SelectSingleNode("./r2:wikiSensor");

                string subject = GetNodeInnerText(wikiNode, "./r2:title", "");
                string body = GetNodeInnerText(wikiNode, "./r2:rawText", "");

                // annotate the text
                AddNewLines(eventDataNode, 8);
                HtmlNode keuiNode = xmlDoc.CreateElement("s1:keui");
                eventDataNode.AppendChild(keuiNode);

                AddAnnotatedData(keuiNode, subject, "s1:titleAnnotated", "s1:titleConcepts", "s1:titleReferences", 9);
                AddAnnotatedData(keuiNode, body, "s1:rawTextAnnotated", "s1:rawTextConcepts", "s1:rawTextReferences", 9);
            }
            catch (Exception ex)
            {
                AddEvent("Exception while annotating new wiki post: " + ex.Message);
            }
            return false;
        }
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:24,代码来源:KEUI.Annotation.cs

示例2: AnnotateIssueUpdate

        public bool AnnotateIssueUpdate(HtmlAgilityPack.XmlDocument xmlDoc)
        {
            try {
                var eventDataNode = xmlDoc.DocumentNode.SelectSingleNode("//ns1:eventData");
                var kesiNode = eventDataNode.SelectSingleNode("./s:kesi");

                // add the keui section
                AddNewLines(eventDataNode, 8);
                HtmlNode keuiNode = xmlDoc.CreateElement("s1:keui");
                eventDataNode.AppendChild(keuiNode);

                // annotate all the comments
                var commentNodes = kesiNode.SelectNodes("./s:issueComment");
                int commentCount = commentNodes != null ? commentNodes.Count : 0;
                for (int commentN = 0; commentN < commentCount; commentN++) {
                    string comment = GetNodeInnerText(kesiNode, string.Format("./s:issueComment[{0}]/s:commentText", commentN + 1), "");
                    HtmlNode commentTextNode = xmlDoc.CreateElement("s1:issueComment");
                    AddNewLines(keuiNode, 9);
                    keuiNode.AppendChild(commentTextNode);
                    AddAnnotatedData(commentTextNode, comment, "s1:commentTextAnnotated", "s1:commentTextConcepts", "s1:commentTextReferences", 10);
                }
                return true;
            }
            catch (Exception ex) {
                AddEvent("Exception while annotating new bug post: " + ex.Message);
                GenLib.Log.LogService.LogException("Exception while annotating new bug post.", ex);
            }
            return false;
        }
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:29,代码来源:KEUI.Annotation.cs

示例3: AnnotateTextToAnnotate

        public bool AnnotateTextToAnnotate(HtmlAgilityPack.XmlDocument xmlDoc)
        {
            try
            {
                var eventDataNode = xmlDoc.DocumentNode.SelectSingleNode("//ns1:eventData");
                var textNode = eventDataNode.SelectSingleNode("./s1:generalText");
                string source = GetNodeInnerText(textNode, "./s1:source", "");
                string text = GetNodeInnerText(textNode, "./s1:text", "");

                // annotate the text and publish it
                Dictionary<string, double> conceptToWeight = new Dictionary<string, double>();
                HashSet<string> references = new HashSet<string>();
                string annotatedBody = AnnotateText(text, conceptToWeight, references);

                AddNewLines(eventDataNode, 8);
                HtmlNode keuiNode = xmlDoc.CreateElement("s1:keui");
                eventDataNode.AppendChild(keuiNode);

                AddAnnotatedData(keuiNode, text, "s1:textAnnotated", "s1:textConcepts", "s1:textReferences", 9);

                return true;
            }
            catch (Exception ex)
            {
                AddEvent("Exception while annotating text to annotate: " + ex.Message);
                GenLib.Log.LogService.LogException("Exception while annotating text to annotate.", ex);
            }
            return false;
        }
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:29,代码来源:KEUI.Annotation.cs

示例4: AnnotateIssueNew

        public bool AnnotateIssueNew(HtmlAgilityPack.XmlDocument xmlDoc)
        {
            try {
                var eventDataNode = xmlDoc.DocumentNode.SelectSingleNode("//ns1:eventData");
                var kesiNode = eventDataNode.SelectSingleNode("./s:kesi");

                // add the keui section
                AddNewLines(eventDataNode, 8);
                HtmlNode keuiNode = xmlDoc.CreateElement("s1:keui");
                eventDataNode.AppendChild(keuiNode);

                // annotate the bug summary
                string description = GetNodeInnerText(kesiNode, "./s:issueDescription", "");
                AddAnnotatedData(keuiNode, description, "s1:issueDescriptionAnnotated", "s1:issueDescriptionConcepts", "s1:issueDescriptionReferences", 9);

                // annotate the bug description
                HtmlNode commentTextNode = xmlDoc.CreateElement("s1:issueComment");
                AddNewLines(keuiNode, 9);
                keuiNode.AppendChild(commentTextNode);
                string comment = GetNodeInnerText(kesiNode, "./s:issueComment/s:commentText", "");
                AddAnnotatedData(commentTextNode, comment, "s1:commentTextAnnotated", "s1:commentTextConcepts", "s1:commentTextReferences", 9);
                return true;
            }
            catch (Exception ex) {
                AddEvent("Exception while annotating IssueNew: " + ex.Message);
                GenLib.Log.LogService.LogException("Exception while annotating IssueNew.", ex);
            }
            return false;
        }
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:29,代码来源:KEUI.Annotation.cs

示例5: AnnotateForumPost

        //public bool AnnotateIssueUpdate(HtmlAgilityPack.XmlDocument xmlDoc)
        //{
        //    try
        //    {
        //        var eventDataNode = xmlDoc.DocumentNode.SelectSingleNode("//ns1:eventData");
        //        var kesiNode = eventDataNode.SelectSingleNode("./s:issue");
        //        string comment = GetNodeInnerText(kesiNode, "./s:issueComment/s:commentText", null);
        //        if (comment == null)
        //            return false;
        //        // annotate the text
        //        AddNewLines(eventDataNode, 8);
        //        HtmlNode keuiNode = xmlDoc.CreateElement("s1:keui");
        //        eventDataNode.AppendChild(keuiNode);
        //        AddAnnotatedData(keuiNode, comment, "s1:commentTextAnnotated", "s1:commentTextConcepts", "s1:commentTextReferences", 9);
        //        return true;
        //    }
        //    catch (Exception ex)
        //    {
        //        AddEvent("Exception while annotating new bug comment: " + ex.Message);
        //        GenLib.Log.LogService.LogException("Exception while annotating new bug comment.", ex);
        //    }
        //    return false;
        //}
        public bool AnnotateForumPost(HtmlAgilityPack.XmlDocument xmlDoc)
        {
            try
            {
                var eventDataNode = xmlDoc.DocumentNode.SelectSingleNode("//ns1:eventData");
                var forumNode = eventDataNode.SelectSingleNode("./r:forumSensor");

                string subject = GetNodeInnerText(forumNode, "./r:subject", "");
                string body = GetNodeInnerText(forumNode, "./r:body", "");

                // annotate the text
                AddNewLines(eventDataNode, 8);
                HtmlNode keuiNode = xmlDoc.CreateElement("s1:keui");
                eventDataNode.AppendChild(keuiNode);

                AddAnnotatedData(keuiNode, body, "s1:bodyAnnotated", "s1:bodyConcepts", "s1:bodyReferences", 9);
                AddAnnotatedData(keuiNode, subject, "s1:subjectAnnotated", "s1:subjectConcepts", "s1:subjectReferences", 9);

                return true;			// return OuterHtml not InnerHtml, otherwise we don't get the newlines printed correctly
            }
            catch (Exception ex)
            {
                AddEvent("Exception while annotating new forum post: " + ex.Message);
                GenLib.Log.LogService.LogException("Exception while annotating new forum post.", ex);
            }
            return false;
        }
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:50,代码来源:KEUI.Annotation.cs

示例6: AnnotateEmail

        public bool AnnotateEmail(HtmlAgilityPack.XmlDocument xmlDoc)
        {
            try
            {
                var eventDataNode = xmlDoc.DocumentNode.SelectSingleNode("//ns1:eventData");
                var mlNode = eventDataNode.SelectSingleNode("./r1:mlsensor");

                string subject = GetNodeInnerText(mlNode, "./r1:subject", "");
                string body = GetNodeInnerText(mlNode, "./r1:content", "");

                // annotate the text
                AddNewLines(eventDataNode, 8);
                HtmlNode keuiNode = xmlDoc.CreateElement("s1:keui");
                eventDataNode.AppendChild(keuiNode);

                AddAnnotatedData(keuiNode, subject, "s1:subjectAnnotated", "s1:subjectConcepts", "s1:subjectReferences", 9);
                AddAnnotatedData(keuiNode, body, "s1:contentAnnotated", "s1:contentConcepts", "s1:contentReferences", 9);

                return true;
            }
            catch (Exception ex)
            {
                AddEvent("Exception while annotating email: " + ex.Message);
                GenLib.Log.LogService.LogException("Exception while annotating email.", ex);
            }
            return false;
        }
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:27,代码来源:KEUI.Annotation.cs

示例7: AnnotateCommit

        public bool AnnotateCommit(HtmlAgilityPack.XmlDocument xmlDoc)
        {
            try
            {
                var eventDataNode = xmlDoc.DocumentNode.SelectSingleNode("//ns1:eventData");
                var kesiNode = eventDataNode.SelectSingleNode("./s:kesi");

                string comment = GetNodeInnerText(kesiNode, "./s:commitMessageLog", "");

                // annotate the text
                AddNewLines(eventDataNode, 8);
                HtmlNode keuiNode = xmlDoc.CreateElement("s1:keui");
                eventDataNode.AppendChild(keuiNode);

                AddAnnotatedData(keuiNode, comment, "s1:commitMessageLogAnnotated", "s1:commitMessageLogConcepts", "s1:commitMessageLogReferences", 9);
            }
            catch (Exception ex)
            {
                AddEvent("Exception while annotating source code: " + ex.Message);
                GenLib.Log.LogService.LogException("Exception while annotating source code.", ex);
            }
            return false;
        }
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:23,代码来源:KEUI.Annotation.cs

示例8: AppendNewWord

        private void AppendNewWord(ref HtmlAgilityPack.HtmlDocument newDoc, string word, WordMatcher matcher, StatisticsDataSet.HighlightStatisticsRow statisticsRow = null)
        {
            HighlightWord matchedWord = null;
            if (matcher.Match(word, out matchedWord))
            {
                HtmlNode span = newDoc.CreateElement("span");
                span.SetAttributeValue("style", matchedWord.Style);
                span.InnerHtml = word;
                newDoc.DocumentNode.ChildNodes.Append(span);

                //if (statisticsRow != null)
                //{
                //    frmStatistics.HighlightStaticsticIncrease(statisticsRow, matchedWord);
                //}
            }
            else
            {
                AppendSimpleWord(ref newDoc, word);
            }
        }
开发者ID:evilch,项目名称:WordHighlight,代码行数:20,代码来源:OneNoteConnect.cs


注:本文中的HtmlAgilityPack.CreateElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。