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


C# Element.AppendChild方法代码示例

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


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

示例1: Parent

 private Element Parent()
 {
     Element parent = new Element("rent", "f", doc);
     Element child;
     for (int i = 0; i < 10; i++)
     {
         child = new Element("foo", "f", doc);
         child.InnerText = i.ToString();
         parent.AppendChild(child);
         child = new Element("bar", "f", doc);
         child.InnerText = i.ToString();
         parent.AppendChild(child);
     }
     return parent;
 }
开发者ID:sq5gvm,项目名称:JabberNet-2010,代码行数:15,代码来源:ElementListTest.cs

示例2: NormaliseStructure

        // merge multiple <head> or <body> contents into one, delete the remainder, and ensure they are owned by <html>
        private void NormaliseStructure(string tag, Element htmlEl)
        {
            Elements elements = this.GetElementsByTag(tag);

            Element master = elements.First; // will always be available as created above if not existent
            if (elements.Count > 1)
            { // dupes, move contents to master
                List<Node> toMove = new List<Node>();

                for (int i = 1; i < elements.Count; i++)
                {
                    Node dupe = elements[i];

                    foreach (Node node in dupe.ChildNodes)
                    {
                        toMove.Add(node);
                    }

                    dupe.Remove();
                }

                foreach (Node dupe in toMove)
                    master.AppendChild(dupe);
            }

            // ensure parented by <html>
            if (!master.Parent.Equals(htmlEl))
            {
                htmlEl.AppendChild(master); // includes remove()
            }
        }
开发者ID:rfcclub,项目名称:NSoup,代码行数:32,代码来源:Document.cs

示例3: HandleOnBeforePresenceOut

        void HandleOnBeforePresenceOut(object sender, Presence pres)
        {
            Element vcardUpdateElem = new Element("x", "vcard-temp:x:update", m_Account.Client.Document);
            Element photoElem = new Element("photo", m_Account.Client.Document);
            vcardUpdateElem.AppendChild(photoElem);

            if (GetAvatarHash(m_Account.Jid) != null) {
                photoElem.InnerText = GetAvatarHash(m_Account.Jid);
            }

            pres.AppendChild(vcardUpdateElem);
        }
开发者ID:jrudolph,项目名称:synapse,代码行数:12,代码来源:AvatarManager.cs

示例4: Process


//.........这里部分代码省略.........
                                // does that mean: int pos of format el in list?
                                Element node = furthestBlock;
                                Element lastNode = furthestBlock;

                                for (int j = 0; j < 3; j++)
                                {
                                    if (tb.OnStack(node))
                                        node = tb.AboveOnStack(node);
                                    if (!tb.IsInActiveFormattingElements(node))
                                    { // note no bookmark check
                                        tb.RemoveFromStack(node);
                                        continue;
                                    }
                                    else if (node == formatEl)
                                    {
                                        break;
                                    }

                                    Element replacement = new Element(Tag.ValueOf(node.NodeName), tb.BaseUri);
                                    tb.ReplaceActiveFormattingElement(node, replacement);
                                    tb.ReplaceOnStack(node, replacement);
                                    node = replacement;

                                    if (lastNode == furthestBlock)
                                    {
                                        // todo: move the aforementioned bookmark to be immediately after the new node in the list of active formatting elements.
                                        // not getting how this bookmark both straddles the element above, but is inbetween here...
                                    }
                                    if (lastNode.Parent != null)
                                    {
                                        lastNode.Remove();
                                    }

                                    node.AppendChild(lastNode);

                                    lastNode = node;
                                }

                                if (StringUtil.In(commonAncestor.NodeName, "table", "tbody", "tfoot", "thead", "tr"))
                                {
                                    if (lastNode.Parent != null)
                                    {
                                        lastNode.Remove();
                                    }

                                    tb.InsertInFosterParent(lastNode);
                                }
                                else
                                {
                                    if (lastNode.Parent != null)
                                    {
                                        lastNode.Remove();
                                    }

                                    commonAncestor.AppendChild(lastNode);
                                }

                                Element adopter = new Element(Tag.ValueOf(name), tb.BaseUri);
                                Node[] childNodes = furthestBlock.ChildNodes.ToArray();
                                foreach (Node childNode in childNodes)
                                {
                                    adopter.AppendChild(childNode); // append will reparent. thus the clone to avvoid concurrent mod.
                                }

                                furthestBlock.AppendChild(adopter);
                                tb.RemoveFromActiveFormattingElements(formatEl);
开发者ID:fengweijp,项目名称:NSoup,代码行数:67,代码来源:TreeBuilderState.cs

示例5: ShowAvailableWeaponsList

        private void ShowAvailableWeaponsList(Entity hardpointEntity)
        {
            _selectedHardpoint = hardpointEntity;
            var hardpoint = hardpointEntity.GetComponent<HardpointComponent>();
            var partsList = Document.GetElementById("availablePartsList");
            partsList.SetProperty("display", "block");
            partsList.RemoveAllChildren();

            var weapons = GetAvailableWeaponsForHardpoint(hardpointEntity);

            foreach(var weapon in weapons)
            {
                var wpnElement = new Element("weapon");
                var name = new Element("name");
                name.InnerRml = weapon.Name;
                wpnElement.AppendChild(name);
                var desc = new Element("description");
                desc.InnerRml = weapon.Description;
                wpnElement.AppendChild(desc);

                wpnElement.Click += (o, e) =>
                {
                    UninstallWeapon();
                    InstallWeapon(weapon.Id);

                };

                partsList.AppendChild(wpnElement);
            }
        }
开发者ID:raycrasher,项目名称:Fell-Sky,代码行数:30,代码来源:ShipRefitScene.cs

示例6: CopySafeNodes

        /// <summary>
        /// Iterates the input and copies trusted nodes (tags, attributes, text) into the destination.
        /// </summary>
        /// <param name="source">source of HTML</param>
        /// <param name="dest">destination element to copy into</param>
        /// <returns>number of discarded elements (that were considered unsafe)</returns>
        private int CopySafeNodes(Element source, Element dest)
        {
            IList<Node> sourceChildren = source.ChildNodes;
            int numDiscarded = 0;

            foreach (Node sourceChild in sourceChildren)
            {
                if (sourceChild is Element)
                {
                    Element sourceEl = (Element)sourceChild;

                    if (_whitelist.IsSafeTag(sourceEl.TagName()))
                    { // safe, clone and copy safe attrs
                        ElementMeta meta = CreateSafeElement(sourceEl);
                        Element destChild = meta.Element;
                        dest.AppendChild(destChild);

                        numDiscarded += meta.NumAttributesDiscarded;
                        numDiscarded += CopySafeNodes(sourceEl, destChild); // recurs
                    }
                    else
                    { // not a safe tag, but it may have children (els or text) that are, so recurse
                        numDiscarded++;
                        numDiscarded += CopySafeNodes(sourceEl, dest);
                    }
                }
                else if (sourceChild is TextNode)
                {
                    TextNode sourceText = (TextNode)sourceChild;
                    TextNode destText = new TextNode(sourceText.GetWholeText(), sourceChild.BaseUri);
                    dest.AppendChild(destText);
                } // else, we don't care about comments, xml proc instructions, etc
            }
            return numDiscarded;
        }
开发者ID:fengweijp,项目名称:NSoup,代码行数:41,代码来源:Cleaner.cs


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