473,406 Members | 2,217 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.

not processing deleted nodes

I have an XML document that I'm looping through and modifying as I go.
Some nodes have to be deleted and I don't want to process their
children after deleting the node.

If my XML structure looks like this:

<top>
<elem>
<elem>first level2</elem>
</elem>
<elem deleteMe="true">
<elem>second level 2</elem>
</elem>
</top>

and the code looks like this:

XmlNodeList nodes = doc.Select("top//elem");
foreach(XmlNode n in nodes)
DoSomething(n);

Say that "DoSomething()" will delete the node that has the "deleteMe"
attribute.

The affect that I'm looking for is that after you delete the <elem
deleteMe="true"> element, you won't process the <elem> inside it (the
one with the inner text of "second level 2"). However, the loop still
processes that element. I'm guessing it's because the XmlNodeList still
has a reference to it. If I requery using the Select() method, the
deleted node and all its children will be excluded. The problem is that
I can't just requery in the middle of doing everything.

I can think of a few somewhat nasty ways to solve this problem, but I
was hoping there would be a clean approach to it. Is there any built in
support for this kind of thing?

Thanks,
Dave

Nov 12 '05 #1
0 1072

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Hubert Hung-Hsien Chang | last post by:
I know you could use the def start_a ..... def end_a ..... to process the <a href=...> anchor </a> tags, but is there a
2
by: Ralf Wahner | last post by:
Dear Masters of XSLT Could I ask you for a clue on the following question? I'd like to use XSLT to transform an XML source file to LaTeX. In the following small example the <para> Element...
6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
4
by: cyclops | last post by:
I'm trying to do XML + XSLT -> Another XML. The source XML contains multiple namespaces and XSLT will handle all possible tags under each name space. ----source---- <document xmlns="..."...
4
by: sboles | last post by:
Hello, I am trying to process each node from XMLHttpRequest.responseXML and set the node's 'className' property based on the value of the 'class' attribute. I have written a recursive function...
3
by: sneill | last post by:
Hi, Can anyone point me in the right direction here? I'm loading an XML file which has a processing instruction (<xsl-stylesheet href="..."/>). I need a cross-browser solution which will...
1
by: Mark | last post by:
I get the following error (see stacktrace) while loading an XMLDocument. The document is huge and it has PI's created from Arbortext's editor. Works fine when I use MSXML2 to load the Document....
4
by: Dave | last post by:
I am trying to run a fucntion to add and format the final XML message. I tried passing the NodeBody to the Function (like I would have done with VB6) but a scope error. What's the best way to do...
10
by: ac.c.2k7 | last post by:
Hello Everyone, The solution to this is to copy the data from the next node into this node and delete the next node!. 1. But if the node to be deleted is the last node. Then what should we do ?...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.