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 / .NET Framework / XML / September 2004

Tip: Looking for answers? Try searching our database.

Removing a bunch of nodes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Victor Hadianto - 22 Sep 2004 07:05 GMT
Hi All,

What is the best way to remove a collection of nodes? For example the
following XML:

<topic>
   <title>Foo</title>
   <title>Bar</title>
   <description>Foo bar</description>
</topic>

At the moment if I want to remove all the title nodes I do the following
XPath //topic/title and loop through the XmlNodeList to remove the node one
by one.

Is there a better/quicker way to do this?

Regards,

Victor
Oleg Tkachenko [MVP] - 22 Sep 2004 13:07 GMT
> <topic>
>     <title>Foo</title>
[quoted text clipped - 7 lines]
>
> Is there a better/quicker way to do this?

I don't think so. What's wrong with your approach?

Signature

Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com

Victor Hadianto - 23 Sep 2004 00:33 GMT
> > <topic>
> >     <title>Foo</title>
[quoted text clipped - 9 lines]
>
> I don't think so. What's wrong with your approach?

Nothing, I thought if there is a quicker way to do it rather than doing the
XPath it'll be better :)

Thanks,

Victor
Oleg Tkachenko [MVP] - 23 Sep 2004 12:06 GMT
>>><topic>
>>>    <title>Foo</title>
[quoted text clipped - 12 lines]
> Nothing, I thought if there is a quicker way to do it rather than doing the
> XPath it'll be better :)

And what's wrong with doing XPath? You can actually traverse DOM using
native DOM methods looking for nodes to remove, but that's gonna be not
so trivial and even probably slower.

Signature

Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com


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.