Gruppering af nodes - XML loop-i-loop-i-loop
Jeg har følgende XML kode som skal bearbejdes i asp:<?xml version="1.0" encoding="ISO-8859-1" ?>
<person id="180138" language="Danish" agegroup="30-40">
Johnny Larsen
<adress>adresse</adress>
<zip>3000</zip>
<occupation>
Marketing
<attrib id="2073">attrib 1</attrib>
<attrib id="4246">attrib 2</attrib>
<attrib id="4247">attrib 3</attrib>
<attrib id="2076">attrib 4</attrib>
</occupation>
<leisure>
Tennis
<attrib id="1075">attrib 1</attrib>
<attrib id="4248">attrib 2</attrib>
<attrib id="2072">attrib 3</attrib>
<attrib id="4245">attrib 4</attrib>
</leisure>
</person>
<person id="180138" language="Danish" agegroup="50-60">
Svend Madsen
<adress>adresse</adress>
<zip>3000</zip>
<occupation>
Admin
<attrib id="2073">attrib 1</attrib>
<attrib id="4246">attrib 2</attrib>
<attrib id="4247">attrib 3</attrib>
<attrib id="2076">attrib 4</attrib>
</occupation>
<leisure>
Golf
<attrib id="1075">attrib 1</attrib>
<attrib id="4248">attrib 2</attrib>
<attrib id="2072">attrib 3</attrib>
<attrib id="4245">attrib 4</attrib>
</leisure>
</person>
<person id="180139" language="Danish" agegroup="40-50">
Kim Holm
<adress>adresse</adress>
<zip>4000</zip>
<occupation>
Education
<attrib id="4247">attrib 1</attrib>
<attrib id="2076">attrib 2</attrib>
</occupation>
<leisure>
Nature
<attrib id="1075">attrib1</attrib>
<attrib id="4245">attrib2</attrib>
</leisure>
</person>
<person id="180140" language="German" agegroup="40-50">
Jan Schmidt
<adress>adresse</adress>
<zip>8000</zip>
<occupation>
Unoccupied
<attrib id="2073">attrib 1</attrib>
<attrib id="4246">attrib 2</attrib>
<attrib id="4247">attrib 3</attrib>
<attrib id="2076">attrib 4</attrib>
</occupation>
<leisure>
Sports
<attrib id="1075">attrib 1</attrib>
<attrib id="4248">attrib 2</attrib>
<attrib id="2072">attrib 3</attrib>
<attrib id="4245">attrib 4</attrib>
</leisure>
</person>
Det skulle være indlysende at værdierne for de forskellige attrib er meget variabel.
Det jeg gerne skal er at få output grupperet på 1) childnoden language i person-noden, og derefter 2) på noden zip.
Derudover skal der for hver enkelt person loopes på alle attrib-noder - en node som jeg ikke kender antallet af forekomster af. Der kan være 0 eller uendeligt.
Det ønskede output skulle gerne være noget i stil med:
(loop på language startes for at gruppere disse)
Language: Danish
(loop på alle personer på noden zip, så den grupperer alle med identisk postnummer)
Postnummer (zip): 3000
Johnny Larsen
Adresse: adresse
Marketing Tennis
(loop på attrib for hhv. occupation og leisure i kolonner)
attrib1 attrib1
attrib2 attrib2
attrib3 attrib3
attrib4 attrib4
Svend Madsen
Adresse: adresse
Admin Golf
(loop på attrib for hhv. occupation og leisure i kolonner)
attrib1 attrib1
attrib2 attrib2
attrib3 attrib3
attrib4 attrib4
(ved forekomst af nyt postnummer, startes næste loop)
Postnummer (zip): 4000
Kim Holm
Adresse: adresse
Education Nature
(loop på attrib for hhv. occupation og leisure i kolonner)
attrib1 attrib1
attrib2 attrib2
(nu er der ikke flere forekomster af language Danish, så næste loop på lanuguage startes)
Language: German
(loop på zip)
Postnummer (zip): 8000
Jan Schmidt
Adresse: adresse
Zip: 8000
Unoccupied Sports
(loop på attrib for hhv. occupation og leisure i kolonner)
attrib1 attrib1
attrib2 attrib2
attrib3 attrib3
attrib4 attrib4
Kort sagt er "hierarkiet" for de loops der skal laves som følger
Loop på language
herunder loop på postnummer
herunder loop på attrib
Hvis mere info ønskes, så spørg løs! Skulle dog være rimelig til at gå til for dem der har prøvet det før, hvilket jeg altså ikke har ;-)
