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


C# HtmlNode.AppendChild方法代码示例

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


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

示例1: AddContentRegions

 private static void AddContentRegions(Dictionary<string, HtmlNode> contentNodes, HtmlNode bodyNode)
 {
     foreach (var contentNode in contentNodes)
     {
         var titleNode = CreateContentTitleNode(contentNode);
         var linkNode = CreateContentLinkNode(titleNode);
         var headerNode = CreateContentHeaderNode(linkNode);
         bodyNode.AppendChild(headerNode);
     }
 }
开发者ID:markrendle,项目名称:PocketIDE,代码行数:10,代码来源:LittleDocumentGenerator.cs

示例2: AddImageNode

 public void AddImageNode(HtmlDocument htmlDoc,HtmlNode new_node,string image_source)
 {
     //<img src=\"{1}\" style=\"height:100%;width:100%;\"/>
     HtmlNode image_node = htmlDoc.CreateElement("img");
     HtmlAttribute src_attr = htmlDoc.CreateAttribute("src", image_source);
     image_node.Attributes.Append(src_attr);
     HtmlAttribute style_attr = htmlDoc.CreateAttribute("style", "height:100%;width:100%;");
     image_node.Attributes.Append(style_attr);
     new_node.AppendChild(image_node);
 }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:10,代码来源:XmlUtil.cs

示例3: TransformHtml

        public override void TransformHtml(Generator generator, Drawable element, HtmlNode node)
        {
            var document = node.OwnerDocument;
            var gridContainer = document.CreateElement("div");
            var style = element.Style;

            // TODO: Move this to GeneratorBlock
            if (style != null)
                gridContainer.Attributes.Add(document.CreateAttribute("class", style));

            // Add our created element to the parent.
            node.AppendChild(gridContainer);

            // IMPORTANT: Unless you know better, always call this at the end. Otherwise the Content of this
            // node will NOT be turned into HTML.
            base.TransformHtml(generator, element, gridContainer);
        }
开发者ID:ncarrillo,项目名称:pantheon,代码行数:17,代码来源:GridGeneratorBlock.cs

示例4: CreateNode

        public static HtmlNode CreateNode(
            HtmlDocument document,
            string name,
            string className = null,
            HtmlNode parentNode = null)
        {
            var node = document.CreateElement(name);

            if (!string.IsNullOrWhiteSpace(className))
            {
                node.SetAttributeValue("class", className);
            }

            if (parentNode != null)
            {
                parentNode.AppendChild(node);
            }

            return node;
        }
开发者ID:sebnilsson,项目名称:WikiDown,代码行数:20,代码来源:HtmlAgilityPackHelper.cs

示例5: TransformHtml

        public override void TransformHtml(Generator generator, Drawable element, HtmlNode node)
        {
            var document = node.OwnerDocument;
            var buttonContainer = document.CreateElement("a");
            var style = element.Style;

            // TODO: Move this to GeneratorBlock
            if (style != null)
                buttonContainer.Attributes.Add(document.CreateAttribute("class", style));

            // Add our created element to the parent.
            node.AppendChild(buttonContainer);

            // For now we'll just add "Hello world" if a Button contains no content.
            if (((Button)element).Text == null)
                buttonContainer.AppendChild(document.CreateTextNode("Browse"));

            // IMPORTANT: Unless you know better, always call this at the end. Otherwise the Content of this
            // node will NOT be turned into HTML.
            base.TransformHtml(generator, element, buttonContainer);
        }
开发者ID:ncarrillo,项目名称:pantheon,代码行数:21,代码来源:ButtonGeneratorBlock.cs

示例6: TransformHtml

        public override void TransformHtml(Generator generator, Drawable element, HtmlNode node)
        {
            // TODO: Flesh this out. Rather bare bones at the moment.
            var document = node.OwnerDocument;
            var newElement = document.CreateElement("div");
            var style = element.Style;

            // TODO: Move this to GeneratorBlock, or not, at least not for this GeneratorBlock impl.
            // Reason being is that I do some ContentProperty voodoo, which isnt appropriate for us here.
            if (style != null)
                newElement.Attributes.Add(document.CreateAttribute("class", style));

            // Add our created element to the parent.
            node.AppendChild(newElement);

            // This is where special handling of Content comes in. I simply loop through the StackPanel and call generate.
            // TODO: Try to generalize this and move it to GeneratorBlock. Will clean things up a bit.
            foreach (var child in ((StackPanel)element).Children)
            {
                generator.Generate(newElement, child);
            }
        }
开发者ID:ncarrillo,项目名称:pantheon,代码行数:22,代码来源:StackPanelGeneratorBlock.cs

示例7: Parse


//.........这里部分代码省略.........
                                {
                                    _oldstate = _state;
                                    _state = ParseState.ServerSideCode;
                                    continue;
                                }
                            }
                        }
                        break;

                    case ParseState.Comment:
                        if (_c == '>')
                        {
                            if (_fullcomment)
                            {
                                if ((Text[_index - 2] != '-') ||
                                    (Text[_index - 3] != '-'))
                                {
                                    continue;
                                }
                            }
                            if (!PushNodeEnd(_index, false))
                            {
                                // stop parsing
                                _index = Text.Length;
                                break;
                            }
                            _state = ParseState.Text;
                            PushNodeStart(HtmlNodeType.Text, _index);
                            continue;
                        }
                        break;

                    case ParseState.ServerSideCode:
                        if (_c == '%')
                        {
                            if (_index < Text.Length)
                            {
                                if (Text[_index] == '>')
                                {
                                    switch (_oldstate)
                                    {
                                        case ParseState.AttributeAfterEquals:
                                            _state = ParseState.AttributeValue;
                                            break;

                                        case ParseState.BetweenAttributes:
                                            PushAttributeNameEnd(_index + 1);
                                            _state = ParseState.BetweenAttributes;
                                            break;

                                        default:
                                            _state = _oldstate;
                                            break;
                                    }
                                    IncrementPosition();
                                }
                            }
                        }
                        break;

                    case ParseState.PcData:
                        // look for </tag + 1 char

                        // check buffer end
                        if ((_currentnode._namelength + 3) <= (Text.Length - (_index - 1)))
                        {
                            if (string.Compare(Text.Substring(_index - 1, _currentnode._namelength + 2),
                                               "</" + _currentnode.Name, StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                int c = Text[_index - 1 + 2 + _currentnode.Name.Length];
                                if ((c == '>') || (IsWhiteSpace(c)))
                                {
                                    // add the script as a text node
                                    HtmlNode script = CreateNode(HtmlNodeType.Text,
                                                                 _currentnode._outerstartindex +
                                                                 _currentnode._outerlength);
                                    script._outerlength = _index - 1 - script._outerstartindex;
                                    _currentnode.AppendChild(script);

                                    PushNodeStart(HtmlNodeType.Element, _index - 1);
                                    PushNodeNameStart(false, _index - 1 + 2);
                                    _state = ParseState.Tag;
                                    IncrementPosition();
                                }
                            }
                        }
                        break;
                }
            }

            // finish the current work
            if (_currentnode._namestartindex > 0)
            {
                PushNodeNameEnd(_index);
            }
            PushNodeEnd(_index, false);

            // we don't need this anymore
            Lastnodes.Clear();
        }
开发者ID:tstrimple,项目名称:DiscoveryEducation,代码行数:101,代码来源:HtmlDocument.cs

示例8: GetStrippedForm

 HtmlNode GetStrippedForm(HtmlNode OriginalForm, List<string> InputElementStrings)
 {
     OriginalForm.RemoveAllChildren();
     foreach (string InputElementString in InputElementStrings)
     {
         HTML InputHtml = new HTML(InputElementString);
         OriginalForm.AppendChild(InputHtml.Html.DocumentNode.FirstChild);
     }
     return OriginalForm;
 }
开发者ID:kartikeyap,项目名称:IronWASP,代码行数:10,代码来源:HTML.cs

示例9: GenerateHTML

        /// <summary>
        /// Traverse the directory structure present in provided DirectoryModel and
        /// create HTML that will represent the directories and files that are found.
        /// </summary>
        /// <param name="directory">Directory containing subdirectories and articles.</param>
        /// <param name="listFileDoc">Object representing HTML document.</param>
        /// <param name="directoryDiv">Container representing div that will contain categories and articles.</param>
        /// <param name="isSourceDir">Bool representing whether directoryDiv, is parent directory of article directory structure.</param>
        static void GenerateHTML(DirectoryModel directory, HtmlDocument listFileDoc, HtmlNode directoryContainerDiv, 
            bool isSourceDir, ref int index, string categoriesUrlText)
        {
            // Hash directory path to be used as unique identifier for
            // folder div's id attribute
            index++;
            string encryptedPath = EncryptStrings.EncryptToMD5String(directory.Path);

            // Create div that will hold folder icon and directory name
            HtmlNode directoryDiv = listFileDoc.CreateElement("div");

            // Container for categories (subdirectories) and article links.
            directoryDiv.SetAttributeValue("class", "directory");
            directoryDiv.SetAttributeValue("id", encryptedPath);

            // Check whether or not current directory, is the parent node
            // of article directory structure (as this is first container to be seen)
            string style = isSourceDir ? String.Format("z-index: {0};", index) : String.Format("z-index: -{0}; display: none", index);
            directoryDiv.SetAttributeValue("style", style);

            // div to hold category header and links to roll back to previous views
            HtmlNode directoryCategoryContainer = listFileDoc.CreateElement("div");
            directoryCategoryContainer.SetAttributeValue("id", "category-container");

            // header for category section of directory div
            HtmlNode directoryHeader = listFileDoc.CreateElement("h2");
            directoryHeader.SetAttributeValue("class", "category-headers");

            // add text node for header
            HtmlNode categoryHeaderText = listFileDoc.CreateTextNode("Categories");
            directoryHeader.AppendChild(categoryHeaderText);
            directoryCategoryContainer.AppendChild(directoryHeader);

            // create div to hold category urls used to roll back to a
            //previous view
            HtmlNode categoryUrlDiv = listFileDoc.CreateElement("div");
            categoryUrlDiv.SetAttributeValue("class", "visited-categories-container");

            // add category url text
            HtmlNode categoryUrlText = listFileDoc.CreateTextNode(categoriesUrlText);
            categoryUrlDiv.AppendChild(categoryUrlText);
            directoryCategoryContainer.AppendChild(categoryUrlDiv);

            // add container for category header and links for rolling back to particular views
            // to the directory container div
            directoryDiv.AppendChild(directoryCategoryContainer);

            HtmlNode categoryRule = listFileDoc.CreateElement("hr");
            categoryRule.SetAttributeValue("class", "header-rule");
            directoryDiv.AppendChild(categoryRule);

            // update current url string to be used by subordinate categories
            string currentUrlName = Path.GetFileName(directory.Path);

            if (categoriesUrlText == String.Empty)
            {
                categoriesUrlText += @"<a href='#' onclick='rollBack("""")'>Home</a>";
            }
            else
            {
                categoriesUrlText += @" > <a href='#' onclick='rollBack(""" + encryptedPath + @""")'>" +
                                    currentUrlName + "</a>";
            }

            // Process subdirectories' contents and generate relevant
            // html.
            if (directory.Subdirectories.Count > 0)
            {
                foreach (DirectoryModel subdirectory in directory.Subdirectories)
                {
                    isSourceDir = false;

                    HtmlNode subDirectoryDiv = listFileDoc.CreateElement("div");
                    subDirectoryDiv.SetAttributeValue("class", "subdirectory");
                    subDirectoryDiv.SetAttributeValue("name", EncryptStrings.EncryptToMD5String(subdirectory.Path));
                    subDirectoryDiv.SetAttributeValue("onclick", "bringToFront(this)");

                    HtmlNode folderParagraph = listFileDoc.CreateElement("p");
                    folderParagraph.SetAttributeValue("class", "folder-name");

                    HtmlTextNode text = listFileDoc.CreateTextNode(Path.GetFileName(subdirectory.Path));
                    folderParagraph.AppendChild(text);

                    subDirectoryDiv.AppendChild(folderParagraph);

                    directoryDiv.AppendChild(subDirectoryDiv);

                    GenerateHTML(subdirectory, listFileDoc, directoryContainerDiv, isSourceDir, ref index, categoriesUrlText);
                }
            }

            // Container for links to show articles.
//.........这里部分代码省略.........
开发者ID:philspain,项目名称:KBLite,代码行数:101,代码来源:ConvertToHtml.cs

示例10: WriteLittleDocument

        private void WriteLittleDocument(KeyValuePair<string, HtmlNode> contentNode, HtmlNode bodyNode)
        {
            bodyNode.AppendChild(contentNode.Value);
            string htmlText = GetHtmlText();

            var htmlBytes = Encoding.Default.GetBytes(htmlText);
            using (var stream = File.Create(contentNode.Key + ".html"))
            {
                stream.Write(htmlBytes, 0, htmlBytes.Length);
            }
            contentNode.Value.Remove();
        }
开发者ID:markrendle,项目名称:PocketIDE,代码行数:12,代码来源:LittleDocumentGenerator.cs

示例11: ReplaceAllChildren

        /// <summary>
        /// Replaces all child nodes with the supplied nodes and indents them +1 tab.
        /// </summary>
        private void ReplaceAllChildren(HtmlNode parent, IEnumerable<HtmlNode> nodes)
        {
            // Preserve the indentation of the parent.
            var parentScope = CreateTextNode();
            var prev = parent.PreviousSibling;
            if (prev == null && parent.ParentNode != null)
                prev = parent.ParentNode.PreviousSibling;
            if (prev != null && prev.NodeType == HtmlNodeType.Text)
            {
                var m = TabsAndSpaces.Match(prev.InnerText);
                if (m.Success)
                    parentScope.InnerHtml += m.Value;
            }

            // Add one tab of indentation for the children.
            var childScope = CreateTextNode(parentScope.InnerText + "\t");

            // Replace all children with supplied nodes (indented).
            parent.RemoveAllChildren();
            foreach (var option in nodes)
            {
                parent.AppendChild(childScope);
                parent.AppendChild(option);
            }

            // Put the closing tag at the same indentation as the opening tag.
            parent.AppendChild(parentScope);
        }
开发者ID:jedmao,项目名称:knockout-viewengine,代码行数:31,代码来源:BoundView.cs

示例12: PopulateIssueInfoNode

        public void PopulateIssueInfoNode(HtmlNode issueInfoNode, HtmlNode kesiNode, HtmlNode mdNode)
        {
            string status = GetNodeInnerText(kesiNode, "./s:issueStatus", null);
            if (status != null)
                issueInfoNode.SetAttributeValue("status", status.EncodeXMLString());
            string resolution = GetNodeInnerText(kesiNode, "./s:issueResolution", null);
            if (resolution != null)
                issueInfoNode.SetAttributeValue("resolution", resolution.EncodeXMLString());
            string productName = GetNodeInnerText(kesiNode, "./s:issueProduct/s:productId", null);
            if (productName != null && GetNodeInnerText(kesiNode, "./s:issueActivity/s:activityWhat", "Product") == "Product")
                issueInfoNode.SetAttributeValue("productName", productName.EncodeXMLString());
            string componentName = GetNodeInnerText(kesiNode, "./s:issueProduct/s:productComponentId", null);
            if (componentName != null && GetNodeInnerText(kesiNode, "./s:issueActivity/s:activityWhat", "Component") == "Component")
                issueInfoNode.SetAttributeValue("componentName", componentName.EncodeXMLString());

            string priority = GetNodeInnerText(kesiNode, "./s:issuePriority", null);
            if (priority != null)
                issueInfoNode.SetAttributeValue("priority", priority.EncodeXMLString());
            string severity = GetNodeInnerText(kesiNode, "./s:issueSeverity", null);
            if (severity != null)
                issueInfoNode.SetAttributeValue("severity", severity.EncodeXMLString());

            string systemOS = GetNodeInnerText(kesiNode, "./s:issueComputerSystem/s:computerSystemOS", null);
            if (systemOS != null)
                issueInfoNode.SetAttributeValue("systemOS", systemOS.EncodeXMLString());
            string systemPlatform = GetNodeInnerText(kesiNode, "./s:issueComputerSystem/s:computerSystemPlatform", null);
            if (systemPlatform != null)
                issueInfoNode.SetAttributeValue("systemPlatform", systemPlatform.EncodeXMLString());
            string productVersion = GetNodeInnerText(kesiNode, "./s:issueProduct/s:productVersion", null);
            if (productVersion != null)
                issueInfoNode.SetAttributeValue("productVersion", productVersion.EncodeXMLString());

            string assignedToName = GetIssueAssignedTo(kesiNode);
            string assignedToUri = GetNodeInnerText(mdNode, "./o:issueAssignedToUri", null);
            if (!string.IsNullOrEmpty(assignedToName)) {
                HtmlNode assignedToNode = issueInfoNode.OwnerDocument.CreateElement("assignedTo");
                issueInfoNode.AppendChild(assignedToNode);
                assignedToNode.SetAttributeValue("name", assignedToName.EncodeXMLString());
                if (!string.IsNullOrEmpty(assignedToUri))
                    assignedToNode.SetAttributeValue("uri", assignedToUri.EncodeXMLString());
            }
            string CCName = GetIssueCCPerson(kesiNode);
            string CCUri = GetNodeInnerText(mdNode, "./o:issueCCPerson", null);		// todo: change this to the right value
            if (!string.IsNullOrEmpty(CCName)) {
                HtmlNode assignedToNode = issueInfoNode.OwnerDocument.CreateElement("CC");
                issueInfoNode.AppendChild(assignedToNode);
                assignedToNode.SetAttributeValue("name", CCName.EncodeXMLString());
                if (!string.IsNullOrEmpty(CCUri))
                    assignedToNode.SetAttributeValue("uri", CCUri.EncodeXMLString());
            }
        }
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:51,代码来源:KEUI.Indexing.cs

示例13: CopyInputElementsIntoForm

 void CopyInputElementsIntoForm(HtmlNode SourceForm, HtmlNode DestinationForm)
 {
     foreach (HtmlNode Node in SourceForm.ChildNodes)
     {
         if (Node.Name.Equals("input"))
         {
             DestinationForm.AppendChild(CopyNodeTopElement(Node, DestinationForm.OwnerDocument));
         }
         else if (Node.ChildNodes.Count > 0)
         {
             CopyInputElementsIntoForm(Node, DestinationForm);
         }
     }
 }
开发者ID:0ks3ii,项目名称:IronWASP,代码行数:14,代码来源:HTML.cs

示例14: AddReferences

 void AddReferences(HtmlNode node, string elementTitle, HashSet<string> references)
 {
     if (node == null)
         return;
     HtmlNode referencesNode = node.OwnerDocument.CreateElement(elementTitle);
     foreach (string reference in references)
         referencesNode.AppendChild(CreateNodeWithTextContent(node.OwnerDocument, "s1:referenceUri", reference));
     node.AppendChild(referencesNode);
 }
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:9,代码来源:KEUI.Annotation.cs

示例15: AddAnnotatedText

        void AddAnnotatedText(HtmlNode node, string elementTitle, string annotatedData, bool putInCDataBlock = true)
        {
            if (node == null)
                return;
            XmlDocument doc = (XmlDocument)node.OwnerDocument;

            HtmlNode annotatedNode;
            if (putInCDataBlock)
                annotatedNode = doc.CreateCDataElementInsideWrapperNode(elementTitle, annotatedData);
            else
                annotatedNode = CreateNodeWithTextContent(doc, elementTitle, annotatedData.EncodeXMLString());
            //annotatedNode.Name = elementTitle;
            node.AppendChild(annotatedNode);
        }
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:14,代码来源:KEUI.Annotation.cs


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