本文整理汇总了C#中XmlNode.RemoveChild方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.RemoveChild方法的具体用法?C# XmlNode.RemoveChild怎么用?C# XmlNode.RemoveChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlNode
的用法示例。
在下文中一共展示了XmlNode.RemoveChild方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveElement
public bool RemoveElement(string elementKey)
{
try
{
XmlDocument cfgDoc = new XmlDocument();
LoadConfigDoc(cfgDoc);
// retrieve the appSettings node
m_Node = cfgDoc.SelectSingleNode("//appSettings");
if (m_Node == null)
{
throw new InvalidOperationException("appSettings section not found");
}
// XPath select setting "add" element that contains this key to remove
m_Node.RemoveChild(m_Node.SelectSingleNode(string.Format("//add[@key='{0}']", elementKey)));
SaveConfigDoc(cfgDoc, m_DocName);
return true;
}
catch
{
return false;
}
}
示例2: SetPropNode
public static void SetPropNode(XmlNode parent, XmlNode child)
{
foreach (XmlNode toRemove in parent.Children(child.Name).ToArray()) {
parent.RemoveChild(toRemove);
}
parent.AppendChild(child);
Save();
}
示例3: Update
/// <summary>
/// Update the permissions in an XML node from the object
/// </summary>
/// <param name="doc">xml document</param>
/// <param name="node">xml root node of permission object</param>
/// <returns>result of update</returns>
public bool Update(XmlDocument doc, XmlNode perm)
{
try
{
// set the corresponding directory
perm.SelectSingleNode("./@Dir").ChildNodes[0].Value = Dir;
// update the options that are supported
perm.SelectSingleNode("./Option[@Name='FileRead']").ChildNodes[0].Value = (OptionFileRead) ? "1" : "0";
perm.SelectSingleNode("./Option[@Name='FileWrite']").ChildNodes[0].Value = (OptionFileWrite) ? "1" : "0";
perm.SelectSingleNode("./Option[@Name='FileDelete']").ChildNodes[0].Value = (OptionFileDelete) ? "1" : "0";
perm.SelectSingleNode("./Option[@Name='FileAppend']").ChildNodes[0].Value = (OptionFileAppend) ? "1" : "0";
perm.SelectSingleNode("./Option[@Name='DirCreate']").ChildNodes[0].Value = (OptionDirCreate) ? "1" : "0";
perm.SelectSingleNode("./Option[@Name='DirDelete']").ChildNodes[0].Value = (OptionDirDelete) ? "1" : "0";
perm.SelectSingleNode("./Option[@Name='DirList']").ChildNodes[0].Value = (OptionDirList) ? "1" : "0";
perm.SelectSingleNode("./Option[@Name='DirSubdirs']").ChildNodes[0].Value = (OptionDirSubdirs) ? "1" : "0";
perm.SelectSingleNode("./Option[@Name='IsHome']").ChildNodes[0].Value = (OptionIsHome) ? "1" : "0";
perm.SelectSingleNode("./Option[@Name='AutoCreate']").ChildNodes[0].Value = (OptionAutoCreate) ? "1" : "0";
// remove any alias definitions
XmlNode aliasesNode = perm.SelectSingleNode("./Aliases");
perm.RemoveChild(aliasesNode);
// if there are aliases, create the node and children
if (Aliases.Count > 0)
{
aliasesNode = doc.CreateElement("Aliases");
foreach (string alias in Aliases)
{
XmlNode aliasNode = doc.CreateElement("Alias");
aliasNode.Value = alias;
aliasesNode.AppendChild(aliasNode);
}
perm.AppendChild(aliasesNode);
}
}
catch (Exception)
{
return false;
}
return true;
}
示例4: RemoveElement
///<summary>
///</summary>
///<param name="Parentelement"></param>
///<param name="Element"></param>
public void RemoveElement(XmlNode Parentelement, XmlNode Element)
{
SectionList.Remove(Element.Name);
Element.RemoveAll();
Parentelement.RemoveChild(Element);
}
示例5: RemoveTeams
void RemoveTeams(XmlNode node)
{
while(node.HasChildNodes) {
node.RemoveChild(node.FirstChild);
}
}