Groups | Blog | Home
all groups > dotnet xml > september 2004 >

dotnet xml : Removing a bunch of nodes


Victor Hadianto
9/21/2004 11:05:03 PM
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,

Oleg Tkachenko [MVP]
9/22/2004 2:07:18 PM
[quoted text, click to view]

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

--
Oleg Tkachenko [XML MVP]
Victor Hadianto
9/22/2004 4:33:07 PM
[quoted text, click to view]

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]
9/23/2004 1:06:02 PM
[quoted text, click to view]

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.

--
Oleg Tkachenko [XML MVP]
AddThis Social Bookmark Button