c# - Remove node from xmlDocument -


this question has answer here:

i trying remove nodes xml document based on input getting below error...

the node removed not child of node.

 xmldocument document = new xmldocument();         document.load(filepath);         if (document == null)             throw new exception("unable load document.");          foreach (string xpath in xpaths)         {              xmlnodelist oldchild = document.selectnodes(xpath, mgr);             if (oldchild != null)             {                 foreach (xmlnode child in oldchild)                 {                     document.removechild(child);                 }             }         }          document.save(filepath); 

can me missign here.

the removechild method working on direct child of node. trying remove inner (not first generation) node accessing root node - document. trick here parent node , remove child it.

child.parentnode.removechild(child) 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -