本文整理汇总了C#中XmlElement.RemoveChild方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElement.RemoveChild方法的具体用法?C# XmlElement.RemoveChild怎么用?C# XmlElement.RemoveChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlElement
的用法示例。
在下文中一共展示了XmlElement.RemoveChild方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Node
public static XmlElement Node(XmlElement node, int index, string name, string attr, string value)
{
XmlElement n = (XmlElement)node.SelectSingleNode(name + "[@" + attr + "='" + value + "']");
if (n != null)
node.RemoveChild(n);
else
{
n = (XmlElement)node.AppendChild(node.OwnerDocument.CreateElement(name));
n.Attributes.Append(node.OwnerDocument.CreateAttribute(attr)).Value = value;
}
if (index >= node.ChildNodes.Count || node.ChildNodes.Count == 0)
node.AppendChild(n);
else
node.InsertBefore(n, node.ChildNodes[index]);
return n;
}
示例2: SetConfigSections
private static void SetConfigSections(XmlElement configSections)
{
XmlElement t;
XmlNode oldSections = configSections.SelectSingleNode("sectionGroup[@name='system.web.extensions' and contains(lower-case(string(@type)), 'version=1.0.61025.0')]", new XContext());
if (oldSections != null)
configSections.RemoveChild(oldSections);
t = Node(configSections, "sectionGroup", "name", "system.web.extensions");
Set(t, "type", "System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
XmlElement scripting = Node(t, "sectionGroup", "name", "scripting");
Set(scripting, "type", "System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
t = Node(scripting, "section", "name", "scriptResourceHandler");
Set(t, "type", "System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
Set(t, "requirePermission", "false");
Set(t, "allowDefinition", "MachineToApplication");
XmlElement webServices = Node(scripting, "sectionGroup", "name", "webServices");
Set(webServices, "type", "System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
t = Node(webServices, "section", "name", "jsonSerialization");
Set(t, "type", "System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
Set(t, "requirePermission", "false");
Set(t, "allowDefinition", "Everywhere");
t = Node(webServices, "section", "name", "profileService");
Set(t, "type", "System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
Set(t, "requirePermission", "false");
Set(t, "allowDefinition", "MachineToApplication");
t = Node(webServices, "section", "name", "authenticationService");
Set(t, "type", "System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
Set(t, "requirePermission", "false");
Set(t, "allowDefinition", "MachineToApplication");
t = Node(webServices, "section", "name", "roleService");
Set(t, "type", "System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
Set(t, "requirePermission", "false");
Set(t, "allowDefinition", "MachineToApplication");
}
示例3: SetPageNamespaces
private void SetPageNamespaces(XmlElement namespaces)
{
XmlNode clear = namespaces.SelectSingleNode("clear");
while (clear != null)
{
List<XmlNode> delete = new List<XmlNode>();
foreach (XmlNode node in namespaces.ChildNodes)
{
delete.Add(node);
if (node == clear)
break;
}
foreach (XmlNode node in delete)
namespaces.RemoveChild(node);
clear = namespaces.SelectSingleNode("clear");
}
Node(namespaces, 0, "clear");
Node(namespaces, "add", "namespace", "System");
Node(namespaces, "add", "namespace", "System.Collections");
Node(namespaces, "add", "namespace", "System.Collections.Generic");
Node(namespaces, "add", "namespace", "System.Collections.Specialized");
Node(namespaces, "add", "namespace", "System.Configuration");
Node(namespaces, "add", "namespace", "System.Text");
Node(namespaces, "add", "namespace", "System.Text.RegularExpressions");
Node(namespaces, "add", "namespace", "System.Linq");
Node(namespaces, "add", "namespace", "System.Xml.Linq");
Node(namespaces, "add", "namespace", "System.Web");
Node(namespaces, "add", "namespace", "System.Web.Caching");
Node(namespaces, "add", "namespace", "System.Web.SessionState");
Node(namespaces, "add", "namespace", "System.Web.Security");
Node(namespaces, "add", "namespace", "System.Web.Profile");
Node(namespaces, "add", "namespace", "System.Web.UI");
Node(namespaces, "add", "namespace", "System.Web.UI.WebControls");
Node(namespaces, "add", "namespace", "System.Web.UI.WebControls.WebParts");
Node(namespaces, "add", "namespace", "System.Web.UI.HtmlControls");
}
示例4: DeleteNode
private static void DeleteNode(XmlElement node, string name, string suffix)
{
XmlNode child = node.SelectSingleNode(name + suffix, new XContext());
if (child != null)
{
node.RemoveChild(child);
}
}
示例5: ParseElement
public override void ParseElement(XmlElement element)
{
string tmpArgVal;
XmlElement tmpXmlEl;
if (element.SelectSingleNode ("documentation") != null) {
this.element.setDocumentation (element.SelectSingleNode ("documentation").InnerText);
element.RemoveChild (element.SelectSingleNode ("documentation"));
}
foreach (XmlElement action in element.ChildNodes) {
//First we parse the elements every action haves:
tmpArgVal = action.GetAttribute("needsGoTo");
if (!string.IsNullOrEmpty(tmpArgVal))
{
currentNeedsGoTo = tmpArgVal.Equals("yes");
}
tmpArgVal = action.GetAttribute("keepDistance");
if (!string.IsNullOrEmpty(tmpArgVal))
{
currentKeepDistance = int.Parse(tmpArgVal);
}
tmpArgVal = action.GetAttribute("not-effects");
if (!string.IsNullOrEmpty(tmpArgVal))
{
activateNotEffects = tmpArgVal.Equals("yes");
}
tmpArgVal = action.GetAttribute("click-effects");
if (!string.IsNullOrEmpty(tmpArgVal))
{
activateClickEffects = tmpArgVal.Equals("yes");
}
tmpArgVal = action.GetAttribute("idTarget");
if (!string.IsNullOrEmpty(tmpArgVal))
{
currentIdTarget = tmpArgVal;
}
currentConditions = new Conditions();
currentEffects = new Effects();
currentNotEffects = new Effects();
currentClickEffects = new Effects();
tmpXmlEl = (XmlElement) action.SelectSingleNode ("condition");
if (tmpXmlEl != null)
new ConditionSubParser_ (currentConditions, chapter).ParseElement (tmpXmlEl);
tmpXmlEl = (XmlElement) action.SelectSingleNode ("effect");
if (tmpXmlEl != null)
new EffectSubParser_ (currentEffects, chapter).ParseElement (tmpXmlEl);
tmpXmlEl = (XmlElement) action.SelectSingleNode ("click-effect");
if (tmpXmlEl != null)
new EffectSubParser_ (currentClickEffects, chapter).ParseElement (tmpXmlEl);
tmpXmlEl = (XmlElement) action.SelectSingleNode ("not-effect");
if (tmpXmlEl != null)
new EffectSubParser_ (currentNotEffects, chapter).ParseElement (tmpXmlEl);
//Then we instantiate the correct action by name.
//We also parse the elements that are unique of that action.
Action currentAction = new Action(0);
switch (action.Name) {
case "examines": currentAction = new Action(Action.EXAMINE, currentConditions, currentEffects, currentNotEffects); break;
case "grabs": currentAction = new Action(Action.GRAB, currentConditions, currentEffects, currentNotEffects); break;
case "use": currentAction = new Action(Action.USE, currentConditions, currentEffects, currentNotEffects); break;
case "talk-to": currentAction = new Action(Action.TALK_TO, currentConditions, currentEffects, currentNotEffects); break;
case "use-with": currentAction = new Action(Action.USE_WITH, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); break;
case "give-to": currentAction = new Action(Action.GIVE_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); break;
case "drag-to": currentAction = new Action (Action.DRAG_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); break;
case "custom":
case "custom-interact":
CustomAction customAction = new CustomAction ((action.Name == "custom") ? Action.CUSTOM : Action.CUSTOM_INTERACT);
tmpArgVal = action.GetAttribute ("name");
if (!string.IsNullOrEmpty (tmpArgVal)) {
currentName = tmpArgVal;
}
customAction.setName (currentName);
tmpXmlEl = (XmlElement) action.SelectSingleNode ("resources");
if (tmpXmlEl != null)
customAction.addResources (parseResources (tmpXmlEl));
currentAction = customAction;
break;
}
//Finally we set al the attributes to the action;
currentAction.setConditions(currentConditions);
currentAction.setEffects(currentEffects);
currentAction.setNotEffects(currentNotEffects);
currentAction.setKeepDistance(currentKeepDistance);
currentAction.setNeedsGoTo(currentNeedsGoTo);
currentAction.setActivatedNotEffects(activateNotEffects);
currentAction.setClickEffects(currentClickEffects);
currentAction.setActivatedClickEffects(activateClickEffects);
this.element.addAction(currentAction);
}
//.........这里部分代码省略.........