本文整理汇总了C#中System.Xml.XmlNode.RemoveChild方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.RemoveChild方法的具体用法?C# XmlNode.RemoveChild怎么用?C# XmlNode.RemoveChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNode
的用法示例。
在下文中一共展示了XmlNode.RemoveChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: findAndRemoveAmazonRR
private static void findAndRemoveAmazonRR(string ns, XmlNode applicationNode, XmlDocument doc)
{
XmlElement e = FindElementForNameWithNamespace("receiver", "name", ns, "com.amazon.inapp.purchasing.ResponseReceiver", applicationNode);
if (e != null)
{
applicationNode.RemoveChild(e);
}
}
示例2: foreach
object IConfigurationSectionHandler.Create(object parent, object configContext, XmlNode section)
{
XmlDocument document = (XmlDocument)section.ParentNode;
XmlNode fixedNode = document.CreateElement("hibernate-configuration");
section.ParentNode.ReplaceChild(fixedNode, section);
foreach (XmlNode node in section.ChildNodes)
{
fixedNode.AppendChild(section.RemoveChild(node));
}
return _originalHandler.Create(parent, configContext, fixedNode);
}
示例3: DeleteElem
public void DeleteElem(NodesBase c)
{
root = doc.FirstChild;
foreach (XmlNode elm in root.ChildNodes)
{
if (c.Elm == elm)
{
root.RemoveChild(elm);
//elm.RemoveChild(elm);
}
else
{
if (DeleteChild(c.Elm, elm) == true) break;
}
}
}
示例4: RemoveElement
/// <summary>
/// Removes a name/value pair in appSettings collection
/// </summary>
/// <returns>A value indicating if the operation was successfull or not</returns>
public bool RemoveElement(string elementKey)
{
try
{
XmlDocument ConfigToObject = new XmlDocument();
LoadConfigToObject(ConfigToObject);
appSettingsNode = ConfigToObject.SelectSingleNode("//appSettings");
if (appSettingsNode == null)
throw new System.InvalidOperationException("appSettings section not found");
// XPath
appSettingsNode.RemoveChild(appSettingsNode.SelectSingleNode("//add[@key='" + elementKey + "']"));
SaveObjectToConfig(ConfigToObject, ConfigFileName);
return true;
}
catch
{
return false;
}
}
示例5: Clean
static void Clean(XmlNode node)
{
var count = node.ChildNodes.Count;
for (var index = count - 1; index >= 0; --index)
{
var child = node.ChildNodes[index];
if (child.NodeType != XmlNodeType.Element)
{
node.RemoveChild(child);
}
}
count = node.ChildNodes.Count;
for (var index = 0; index < count; ++index)
{
var child = node.ChildNodes[index];
Clean(child);
}
}
示例6: HTTPRedirect
/// <summary>
/// Transfers the message to the given endpoint using the HTTP-Redirect binding.
/// </summary>
protected static void HTTPRedirect(SAMLAction action, IDPEndPointElement endpoint, XmlNode message)
{
if (message.FirstChild is XmlDeclaration)
message.RemoveChild(message.FirstChild);
HttpRedirectBindingBuilder builder = new HttpRedirectBindingBuilder();
if (action == SAMLAction.SAMLRequest)
builder.Request = message.OuterXml;
else
builder.Response = message.OuterXml;
builder.signingKey = IDPConfig.IDPCertificate.PrivateKey;
UriBuilder url = new UriBuilder(endpoint.Url);
url.Query = builder.ToQuery();
HttpContext.Current.Response.Redirect(url.ToString(), true);
}
示例7: Sort
public XmlNode Sort(XmlNode node)
{
var children = new List<XmlNode>();
var sorting = GetSorting();
foreach (XmlNode childNode in node.ChildNodes)
{
children.Add(childNode);
SortChildren(childNode);
}
// Creates a copy of the sort order the elments were added in on the node
var originalSortOrder = children.ToArray();
children.Sort((x, y) =>
{
if (!sorting.ContainsKey(x.Name) || !sorting.ContainsKey(y.Name)) return 0;
var xSort = sorting[x.Name];
var ySort = sorting[y.Name];
//General Position
if (xSort.Position != ySort.Position) return xSort.Position.CompareTo(ySort.Position);
//Sub-Position if positions are the same
if (xSort.Level != ySort.Level) return xSort.Level.CompareTo(ySort.Level);
//Relative Index based on the order the part was added
return Array.IndexOf(originalSortOrder, x).CompareTo(Array.IndexOf(originalSortOrder, y));
});
for (var i = 0; i < node.ChildNodes.Count; i++)
{
node.RemoveChild(node.ChildNodes[i]);
}
foreach (var child in children)
{
node.AppendChild(child);
}
return node;
}
示例8: PreprocessParameters
public XmlNode PreprocessParameters(NetReflectorTypeTable typeTable, XmlNode inputNode)
{
var dobNode = (from node in inputNode.ChildNodes
.OfType<XmlNode>()
where node.Name == "dob"
select node).SingleOrDefault();
if (dobNode != null)
{
var dob = DateTime.Parse(dobNode.InnerText);
inputNode.RemoveChild(dobNode);
var ageNode = inputNode.OwnerDocument.CreateElement("age");
ageNode.InnerText = Convert.ToInt32(
(DateTime.Now - dob).TotalDays / 365)
.ToString();
inputNode.AppendChild(ageNode);
}
return inputNode;
}
示例9: SortChildNodes
private static void SortChildNodes(XmlNode node)
{
var sl = new SortedList<string, XmlNode>();
if (node.Attributes != null)
{
int i = 0;
foreach (XmlNode n in node.ChildNodes)
sl[n.OuterXml + "\"" + i++] = n;
foreach (var n in sl.Values)
node.RemoveChild(n);
foreach (var n in sl.Values)
node.AppendChild(n);
}
foreach (XmlNode chNode in node.ChildNodes)
SortAttribs(chNode);
}
示例10: DeleteAlbumsWithPriceLessThan20
private static void DeleteAlbumsWithPriceLessThan20(XmlNode node)
{
var nodeList = node.ChildNodes;
List<XmlNode> nodesToDelete = new List<XmlNode>();
foreach (XmlNode album in nodeList)
{
float currentAlbumPrice = float.Parse(album["price"].InnerText, CultureInfo.InvariantCulture);
if (currentAlbumPrice < 20.0)
{
nodesToDelete.Add(album);
}
}
foreach (XmlNode album in nodesToDelete)
{
Console.WriteLine("Album called \"{0}\"'s price is {1} so it was deleted.", album["name"].InnerText, album["price"].InnerText);
node.RemoveChild(album);
}
}
示例11: WriteTo
public override System.Xml.XmlNode WriteTo(XmlNode parent)
{
XmlElement stringsElement = parent.SelectSingleNode("child::" + name) as XmlElement;
if (stringsElement != null)
{
parent.RemoveChild(stringsElement);
}
stringsElement = parent.OwnerDocument.CreateElement(name);
parent.AppendChild(stringsElement);
if (values != null)
{
foreach (string item in values)
{
XmlElement itemElement = parent.OwnerDocument.CreateElement("Item");
itemElement.InnerText = item;
stringsElement.AppendChild(itemElement);
}
}
return null;
}
示例12: AddTypes
static void AddTypes (XmlNode dest, XmlDocument source, string sourceDirectory)
{
var types = source.SelectSingleNode ("/Overview/Types");
if (types == null)
return;
foreach (XmlNode ns in types.ChildNodes) {
var n = ns.Attributes ["Name"].Value;
var nsd = dest.SelectSingleNode (string.Format ("Namespace[@Name='{0}']", n));
if (nsd == null) {
nsd = dest.OwnerDocument.CreateElement ("Namespace");
AddAttribute (nsd, "Name", n);
dest.AppendChild (nsd);
}
foreach (XmlNode t in ns.ChildNodes) {
if (!TypeInVersions (sourceDirectory, n, t))
continue;
var c = dest.OwnerDocument.ImportNode (t, true);
AddAttribute (c, "SourceDirectory", sourceDirectory);
nsd.AppendChild (c);
}
if (nsd.ChildNodes.Count == 0)
dest.RemoveChild (nsd);
}
}
示例13: ParseInstallNode
private void ParseInstallNode(XmlNode installNode)
{
XmlNodeList components = installNode.SelectNodes("component");
if (components.Count == 0)
{
//remove parent install node
installNode.ParentNode.RemoveChild(installNode);
ProceedUnattendedSetup();
}
else
{
//remove current node and start installation
XmlElement componentNode = (XmlElement)components[0];
string componentCode = componentNode.GetAttribute("code");
string componentVersion = componentNode.GetAttribute("version");
string xml = componentNode.InnerXml;
installNode.RemoveChild(componentNode);
if (!string.IsNullOrEmpty(componentCode))
{
ScopeNode componentsNode = scopeTree.Nodes[0] as ScopeNode;
scopeTree.SelectedNode = componentsNode;
ComponentsControl ctrl = componentsNode.ResultView as ComponentsControl;
ctrl.InstallComponent(componentCode, componentVersion, xml);
}
}
}
示例14: SetNodeText
/**
* Sets the text of this node. All the child's node are deleted and a new
* child text node is created.
* @param domDocument the <CODE>Document</CODE> that contains the node
* @param n the <CODE>Node</CODE> to add the text to
* @param value the text to add
*/
public bool SetNodeText(XmlDocument domDocument, XmlNode n, String value)
{
if (n == null)
return false;
XmlNode nc = null;
while ((nc = n.FirstChild) != null) {
n.RemoveChild(nc);
}
n.AppendChild(domDocument.CreateTextNode(value));
return true;
}
示例15: RemoveAllNodes
private static void RemoveAllNodes(XmlDocument doc, XmlNode targetsNode, string xpath)
{
var matchingNodes = doc.SelectNodes(xpath);
foreach (XmlNode node in matchingNodes)
targetsNode.RemoveChild(node);
}