0
Answer

C# + XML + nested loops

Kev D

Kev D

19y
2.4k
1
Hello, I'm working on a C# console program. Now I've encountered the following problem: I read data from a MS-SQL database and create Article objects with this data (own class). An Article object exists out of the following members: custIDa, custIDb, docID, accountNr, tCode, tTarif, VAT. A customer can have multiple articles (so when custIDa is for example 1 it can have docID = 1 and docID = 2 (so 2 articles)). I add every Article object to an ArrayList (and maybe I'll sort it). What I want to accomplish is the following: I want to run through the ArrayList and write the Article-data to XML like this:
I think I'll have to do this with a nested loop, 1 to check if custIDa is the same or has changed and one for the docID's. So custIDa can occur multiple times with everytime a changed docID (you could state that it's a combined primary key as in SQL). Anyone can help me out with this or has any ideas to help me out 'cause I'm really stuck here :( Thanks in advance! PS: Sorry for my English, I'm from Belgium ;)