Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

query xml data to text output

Avatar of JEsradi
JEsradi asked on
XML.NET ProgrammingC#
31 Comments1 Solution510 ViewsLast Modified:
Background:
I'm pretty good with VBA, VB6, and competent with VB.NET and javascript.  But the new boss is a C# guy.  All new projects going forward will be C#, so I've been learning, teaching myself, betwixt ongoing VB projects.  I'm past the 'Hello, world' stage, but not by much!
Yesterday he comes to me with a request to convert a VBA function I wrote to format data from an Access database, into a C# class that formats that data, now in an xml file, the same way.  So I know everything that needs to be done, but have absolutely no idea how to go about it!
I've got big points for anybody who's willing to hold my hand and walk me thru this!

Scenario (see attached 80018210.xml):
The xml data describes a daily report from a rail-flaw detection vehicle, using induction and ultrasonics to test railroad tracks for defects (cracks, wear, internal flaws).
The Reports collection contains the service data for the day.  There is one Report node for each customer serviced in a day.
Within a Report node, there is one Location node per customer location or within a location with a non-contiguous milepost.
Within a Location node, there is a Movement node for every action performed on the track(or road) in that location, as well as a Defect node, if any defects were marked.
In the Movement node, an MCODE of 0 represents the beginning of a test, an MCODE of 7 represents the movement half of a defect record, and an MCODE of 5 marks the end of a test.
The example report describes the 'worst case' scenario for the purposes of the output I need:  there are 4 Location nodes (LOCID), but only 2 distinct customer locations (LNNUM), 7100 and 7101, with the added twist that 7101 exists between different segments of 7100.

Output format:
Each customer location, by LNNUM, is output to a separate file.
Each file begins with a Header line, containing:  LNNUM, Total miles tested, number of tested segments, CAR number, number of Defects found, Date, Operator, Total test time, total Delay time, etc.
The next lines describe the tested segments: the TrackID, and the mileposts at the beginning and end of the test.
If any defects were found within the milepost range of a tested segment, that defect must be listed under the segment in which it was found.  Defect info includes milepost, trackside (L/R), defect type, defect size, defect number, etc.

Requirements:
an array of unique LNNUMs in the Report
a way to combine the Movement nodes of multiple Location nodes into a single dataset or hashtable, so total time and miles for the specific LNNUM can be calculated.
a technique to capture the mileposts of the 0-5 pairs that comprise a test segment.
a way to insert the defects directly below the correct test segment in the set of test segments.

Plea:
If anyone would like to take a shot at this with me, please let me know soonest...my bossman knows I'm on a learning curve - he's given me to Tuesday next to come up with something.  Thank goodness for the 4th of July, or he'd want it Monday!

In the meantime, it's back to search-and-skim, looking for answers to questions I'm not sure how to ask!

Ginny
80018210.xml
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Commented:
This problem has been solved!
Unlock 1 Answer and 31 Comments.
See Answers