Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. How to delete a xml node with all attributes and start, end tag of the xml node in c#-- urgent

How to delete a xml node with all attributes and start, end tag of the xml node in c#-- urgent

Scheduled Pinned Locked Moved XML / XSL
helpcsharphtmlxmltutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vishnu Narayan Mishra
    wrote on last edited by
    #1

    Hello every one! I have a little problem of deleting xml node. I have deleted successfully the attributes of node but opening and closing tag of node was not deleted and . But i have to delete also the opening and clsing tag ofthe node means I have to remove every thing of .How can I do this. following is the structure of my xml file -------------------------------------------------------- 0 1.0.1 c1f13323-209b-4b0e-ad8d-d34f64d34c28 2007-10-25T11:47:10.515625+05:30 SUBHASH\Login Subhash C:\Documents and Settings\Login Subhash\Desktop\main.html Adding New Html Help 3 ... .... -------------------------------------------------------- following is my c# code -------------------------------------------------------- //int intRefId = Convert.ToInt32(Request.QueryString["RefId"]); int intRefId = 3; string strXPath = "/LinkInformation/ScreensToSupport/ScreenToSupport/SupportItems/ScreenSupportItem[RefId='" + intRefId + "']"; XmlNode newParent = doc.SelectSingleNode(strXPath); XmlNodeList newChildNodeList = newParent.ParentNode.ChildNodes; foreach (XmlNode node1 in newChildNodeList) { foreach (XmlNode node in node1) { if (node.Name == "LinkURL" && node.InnerText == hdntxtUrlLink.Text) { intCount++; } if (node.Name == "LinkText" && node.InnerText == hdntxtUrlTitle.Text) { intCount++; }

    L 1 Reply Last reply
    0
    • V Vishnu Narayan Mishra

      Hello every one! I have a little problem of deleting xml node. I have deleted successfully the attributes of node but opening and closing tag of node was not deleted and . But i have to delete also the opening and clsing tag ofthe node means I have to remove every thing of .How can I do this. following is the structure of my xml file -------------------------------------------------------- 0 1.0.1 c1f13323-209b-4b0e-ad8d-d34f64d34c28 2007-10-25T11:47:10.515625+05:30 SUBHASH\Login Subhash C:\Documents and Settings\Login Subhash\Desktop\main.html Adding New Html Help 3 ... .... -------------------------------------------------------- following is my c# code -------------------------------------------------------- //int intRefId = Convert.ToInt32(Request.QueryString["RefId"]); int intRefId = 3; string strXPath = "/LinkInformation/ScreensToSupport/ScreenToSupport/SupportItems/ScreenSupportItem[RefId='" + intRefId + "']"; XmlNode newParent = doc.SelectSingleNode(strXPath); XmlNodeList newChildNodeList = newParent.ParentNode.ChildNodes; foreach (XmlNode node1 in newChildNodeList) { foreach (XmlNode node in node1) { if (node.Name == "LinkURL" && node.InnerText == hdntxtUrlLink.Text) { intCount++; } if (node.Name == "LinkText" && node.InnerText == hdntxtUrlTitle.Text) { intCount++; }

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Use an XPath statement to find the node you want to remove then call node.ParentNode.RemoveChild(node)

      XmlNode node = doc.SelectSingleNode("//x/y/z/ScreenSupportItem");
      node.ParentNode.RemoveChild(node);

      V 1 Reply Last reply
      0
      • L led mike

        Use an XPath statement to find the node you want to remove then call node.ParentNode.RemoveChild(node)

        XmlNode node = doc.SelectSingleNode("//x/y/z/ScreenSupportItem");
        node.ParentNode.RemoveChild(node);

        V Offline
        V Offline
        Vishnu Narayan Mishra
        wrote on last edited by
        #3

        Thanks a lot sir, its working fine....

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups