本文整理汇总了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;
}
示例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()
}
}
示例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);
}
示例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);
示例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);
}
}
示例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;
}