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


C# XmlNode.RemoveChild方法代码示例

本文整理汇总了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;
        }
    }
开发者ID:webgrid,项目名称:WebGrid,代码行数:31,代码来源:Xml.cs

示例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();
 }
开发者ID:foxor,项目名称:unity-nls,代码行数:8,代码来源:UserProperty.cs

示例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;
	}
开发者ID:sancsoft,项目名称:FileZilla.NET,代码行数:49,代码来源:FilezillaPermission.cs

示例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);
 }
开发者ID:liujf5566,项目名称:Tool,代码行数:10,代码来源:XmlText.cs

示例5: RemoveTeams

 void RemoveTeams(XmlNode node)
 {
     while(node.HasChildNodes) {
         node.RemoveChild(node.FirstChild);
     }
 }
开发者ID:maxrchung,项目名称:ARIA,代码行数:6,代码来源:GameManager.cs


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