473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Delete the selected element from XML file

anyone know how to delete the selected element from xml file?

Nov 10 '09 #1
6 3207
nbiswas
149 100+
Try this

Expand|Select|Wrap|Line Numbers
  1. XmlDocument doc = new XmlDocument();
  2. doc.Load(fileName);
  3. XmlNodeList nodes = doc.SelectNodes("some-xpath-query");
  4. for (int i = nodes.Count - 1; i >= 0; i--)
  5. {
  6.     nodes[i].ParentNode.RemoveChild(nodes[i]);
  7. }
  8. doc.Save(fileName);

Also look into this link

http://www.andreas-kraus.net/blog/de...l-file-aspnet/

Hope this helps
Nov 10 '09 #2
i want to be implement into C# windows form not in ASP.net

The code you provided cannot be use in C# form app.
Nov 11 '09 #3
nbiswas
149 100+
Come on.. It is not related to windows form or asp.net. Xmldocument is a class that will help u to accomplish the task..
Nov 11 '09 #4
will you mind to explain "some-xpath-query" what should i do in this?

Sorry, i am new comer of C# and also in Programming.
Nov 11 '09 #5
nbiswas
149 100+
Look into this tutorial
http://www.ziggyware.com/readarticle.php?article_id=36

and also this

http://www.codeguru.com/csharp/cshar...cle.php/c7589/

hope this may help you initially
Nov 11 '09 #6
hey, tks for helping but i still don't understand how to use it. It does not allow me to delete the selected row. Never mind i don't think i will implement the delete button in my C# xml project.

tks again.
Nov 11 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: audipen | last post by:
Hi, I've facing a certain problem with selected item in the ClassView. Basically here is what I do - When the user right-clicks on an item in the ClassView ,he can select a pop-up menu...
3
by: Brian Underhill via DotNetMonster.com | last post by:
I am trying to delete an element from an array. I have an array of 52 elements and I want to search for an element and delete it. Therefore, making it an array of 51 elements. is it just ...
7
by: python | last post by:
after del list , when I use it again, prompt 'not defined'.how could i delete its element,but not itself? except list.remove(val) ,are there other ways to delete list 's elements? and , I...
7
by: JH Programmer | last post by:
Hi, is there any ways that allow us to delete an element in between? say int_val: 1 int_val: 2 int_val: 3
2
by: cdun2 | last post by:
Hello, I have some code that reads each line of a text file, and if a line is found where the length of the string in the line is 384, it writes the line to a text file. The other step that I...
7
by: =?utf-8?B?5YiY5piK?= | last post by:
Hi, folks, Is it possible to delete an element from a sorted array with O(1) time? Best regards
2
by: hellboss | last post by:
HI ! I am workin wit asp.net vs 05 , I have some document file in my local directory and its corresponding path and its file name is strored in a the database table. In the Page 1, i have listed...
1
by: sunir | last post by:
I m tryin to delete selected line from a file.somebody help me.
1
by: George21 | last post by:
Hi. I'm trying to delete selected item in listview. Can anyone help me? How can i delete selected item in Listview from menu using for loop?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.