Пример #1
0
 /// <summary>
 /// Deletes a specified XPATH
 /// </summary>
 /// <param name="mod">The mod.</param>
 private void Delete(XmlDelete mod)
 {
     try
     {
         XmlNodeList nodes = ReturnMatchingNodes(mod.xpath);
         if (nodes.Count > 0)
         {
             foreach (XmlNode node in nodes)
             {
                 //If we are working on an attribute, we need to cast it and delete it from its owner element.
                 if (node.NodeType == XmlNodeType.Attribute)
                 {
                     ((XmlAttribute)node).OwnerElement.Attributes.Remove((XmlAttribute)node);
                 }
                 else
                 {
                     node.ParentNode.RemoveChild(node);
                 }
             }
         }
     }
     catch (Exception i)
     {
         LogFailureAndOptionallyThrow(mod.xpath, "delete", i);
     }
 }
Пример #2
0
 /// <summary>
 /// Deletes a specified XPATH
 /// </summary>
 /// <param name="mod">The mod.</param>
 private void Delete(XmlDelete mod)
 {
     try
     {
         XmlNodeList nodes = ReturnMatchingNodes(mod.xpath);
         if (nodes.Count > 0)
         {
             foreach (XmlNode node in nodes)
             {
                 //If we are working on an attribute, we need to cast it and delete it from its owner element.
                 if (node.NodeType == XmlNodeType.Attribute)
                 {
                     ((XmlAttribute)node).OwnerElement.Attributes.Remove((XmlAttribute)node);
                 }
                 else
                 {
                     node.ParentNode.RemoveChild(node);
                 }
             }
         }
     }
     catch (Exception i)
     {
         LogFailureAndOptionallyThrow(mod.xpath, "delete", i);
     }
 }