Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

how to remove closing tag of a node of xml file in asp.net and c#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tosudesh2005@gmail.com - 01 Mar 2008 05:01 GMT
hi all

I write code like this to remove perticular node. but it left closing
tag in xml file. but i want remove this closing tag also.
------------------------------------------------------------
string filename = Server.MapPath("DutyStatus.xml").ToString();
XmlNodeList objnodelst;
XmlDocument doc = new XmlDocument();
doc.Load(filename);
objnodelst = doc.SelectNodes("/DutyStatus/
DSNO[@ID='30006006200']");
foreach (XmlNode objnode in objnodelst)
{
objnode.RemoveAll();
doc.Save(Server.MapPath("DutyStatus.xml"));
}

my xml file look like this
-------------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
- <DutyStatus>
- <DSNO ID="30006006200">
<UserID>AMIT KUMAR - 17</UserID>
<Status>frmDutyStart</Status>
</DSNO>
</DutyStatus

after deleting this node my file look like this
------------------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
- <DutyStatus>
<DSNO />
</DutyStatus

i want remove <DSNO/> tag also

from
sudesh
Arne Vajhøj - 01 Mar 2008 05:25 GMT
> I write code like this to remove perticular node. but it left closing
> tag in xml file. but i want remove this closing tag also.
[quoted text clipped - 29 lines]
>
> i want remove <DSNO/> tag also

You are only removing content below objnode.

You need to remove objnode from its parent.

Arne
tosudesh2005@gmail.com - 01 Mar 2008 12:00 GMT
> tosudesh2...@gmail.com wrote:
> > I write code like this to remove perticular node. but it left closing
[quoted text clipped - 38 lines]
>
> - Show quoted text -

thanks dear,
i got solution of my problem.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.