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


C# DomNode.appendChild方法代码示例

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


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

示例1: Copy

        /// <summary>
        /// Copy all children from 'source' to 'dest', within the context of the specified page.
        /// </summary>
        /// <param name="page">the page which the nodes belong to</param>
        /// <param name="source">the node to copy from</param>
        /// <param name="dest">the node to copy to</param>
        /// <param name="handleXHTMLAsHTML">if true elements from the XHTML namespace are handled as HTML elements instead of DOM elements</param>
        private static void Copy(SgmlPage page, XmlNode source, DomNode dest, bool handleXHTMLAsHTML)
        {
            XmlNodeList nodeChildren = source.ChildNodes;
            for (int i = 0; i < nodeChildren.Count; i++)
            {
                XmlNode child = nodeChildren.Item(i);
                switch (child.NodeType)
                {
                    case XmlNodeType.Element:
                        DomNode childXml = CreateFrom(page, child, handleXHTMLAsHTML);
                        dest.appendChild(childXml);
                        Copy(page, child, childXml, handleXHTMLAsHTML);
                        break;

                    case XmlNodeType.Text:
                        dest.appendChild(new DomText(page, child.Value));
                        break;

                    case XmlNodeType.CDATA:
                        dest.appendChild(new DomCDataSection(page, child.Value));
                        break;

                    case XmlNodeType.Comment:
                        dest.appendChild(new DomComment(page, child.Value));
                        break;

                    case XmlNodeType.ProcessingInstruction:
                        dest.appendChild(new DomProcessingInstruction(page, child.Name, child.Value));
                        break;

                    default:
                        LOG.Warn("NodeType " + child.NodeType + " (" + child.Name + ") is not yet supported.");
                }
            }
        }
开发者ID:codefrom,项目名称:HtmlUnit.NET,代码行数:42,代码来源:XmlUtil.cs

示例2: AppendChild

 /// <summary>
 /// Recursively appends a {@link Node} child to {@link DomNode} parent.
 /// </summary>
 /// <param name="page">the owner page of {@link DomElement}s to be created</param>
 /// <param name="parent">the parent DomNode</param>
 /// <param name="child">the child Node</param>
 /// <param name="handleXHTMLAsHTML">if true elements from the XHTML namespace are handled as HTML elements instead of DOM elements</param>
 public static void AppendChild(SgmlPage page, DomNode parent, XmlNode child, bool handleXHTMLAsHTML)
 {
     XmlDocumentType documentType = child.OwnerDocument.DocumentType;
     if (documentType != null && page is XmlPage)
     {
         DomDocumentType domDoctype = new DomDocumentType(
                 page, documentType.Name, documentType.PublicId, documentType.SystemId);
         ((XmlPage)page).setDocumentType(domDoctype);
     }
     DomNode childXml = CreateFrom(page, child, handleXHTMLAsHTML);
     parent.appendChild(childXml);
     Copy(page, child, childXml, handleXHTMLAsHTML);
 }
开发者ID:codefrom,项目名称:HtmlUnit.NET,代码行数:20,代码来源:XmlUtil.cs


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