473,387 Members | 1,495 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,387 software developers and data experts.

Need Help With Detecting Element Block "Exit"

Hi, all.
This should be pretty easy:

When parsing my XmlDocument object with a validating
reader, what's the proper way to detect when it
"exits" an element's block? It's the first time
I've needed to toggle a bool when entering and
exiting one; I tried to trap the exit with
'case "</block>":', but that doesn't work.

FWIW, I have the XML representation of a table,
and some of its rows have a nested table. I want to
add a parent ID to each nested table. Maybe there's
a better way to do this?

Oh, I only need a small subset of the large XML doc,
so I'm not planning on deserializing it into a complex
object.

Thanks!
bn
Nov 12 '05 #1
1 1399
"beachnut" <ho**********@hotmail.com> wrote in message news:bb**************************@posting.google.c om...
When parsing my XmlDocument object with a validating
reader, what's the proper way to detect when it
"exits" an element's block?
You probably have a loop that looks like,

while ( validatingReader1.Read( ) )
{
;
}

So what you can do is check the NodeType to see if
it's XmlNodeType.EndElement.

string atomBlock = validatingReader1.NameTable.Get( "block");
while ( validatingReader1.Read( ) )
{
if ( validatingReader1.NodeType == XmlNodeType.EndElement )
{
if ( validatingReader1.LocalName == atomBlock )
{
// Do something when the </block> end tag has been parsed.
}
}
}

Another approach is to subclass XmlValidatingReader and override the
Read( ) method (to call base.Read( ) and then check the NodeType and
LocalName to raise an event notification or something when it hits the end
tags it's interested in), then use an instance of your specialized XmlValidating-
Reader to load your XmlDocument.
and some of its rows have a nested table. I want to
add a parent ID to each nested table. Maybe there's
a better way to do this?


It's a relational question, not an XML question. In XML, the "nested table"
is contained by a parent element, therefore the notion of having a parent ID
is redundant. If you have an XmlNode in the nested table, you can move
to a node of the parent table using the ParentNode property.

Another issue to watch out for with having these parent IDs (as it is an issue
when dealing with any sort of data redundancy) is keeping them up-to-date
if you ever relocate a portion of the node tree elsewhere.

Sometimes data redundancy is a good thing (balancing data normalization
with locality of reference), but in this case when the parent nodes are there
for you I don't believe it's worthwhile. What do you want to do with an ID
to the parent ... using it to search the entire document isn't going to expedite
anything.
Derek Harmon
Nov 12 '05 #2

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

Similar topics

7
by: Brett | last post by:
What is the C# equivalent of VB.NET's Exit Sub? Thanks, Brett
24
by: Agnes | last post by:
I need to disable the exit button in the form . However, the min. and max. button need to keep it How ? Thanks a lot From Agnes
19
by: ern | last post by:
Right now I'm using exit(0) to terminate my program. My program is a console .exe application. After the "exit(0)" line of code is encountered, the console application waits for an enter press,...
2
by: Serious_Practitioner | last post by:
Good day, and thank you in advance for any assistance. I'm having trouble with something that I'm trying for the first time. Using Access 2000 - I want to run a function either on the click of a...
13
by: Vincent Delporte | last post by:
Hi I'm a Python newbie, and would like to rewrite this Perl scrip to be run with the Asterisk PBX: http://www.voip-info.org/wiki/view/Asterisk+NetCID Anyone knows if those lines are...
1
by: JEJE | last post by:
To All, What is the difference between the following Exit code?? Exit (0)?? Exit(1)?? Exit (2)??
2
by: dstork | last post by:
Anyone know how to rename the "Exit Access" command at the bottom of the Office menu. I'd like to rename it to "Exit" as I had done in previous versions of Access. I know I can disable it with ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.